FireMonkey ListView 自动计算行高
发布时间:2020-12-15 04:36:22 所属栏目:大数据 来源:网络整理
导读:说明:展示 ListView 视其每一行 Item 的 Detail 字串长度自动调整高度(可每行高度不同)。 适用:Delphi XE7 / XE8 源码下载: DetailStr: [ .. ] String = i:= = = Random( = DetailStr[r].Substring( = span style="color: #0000ff;"procedure TForm1.Li
说明:展示 ListView 视其每一行 Item 的 Detail 字串长度自动调整高度(可每行高度不同)。 适用:Delphi XE7 / XE8 源码下载: DetailStr: [..] String =
i:=
== Random(= DetailStr[r].Substring(=<span style="color: #0000ff;">procedure TForm1.ListView1UpdateObjects(<span style="color: #0000ff;">const<span style="color: #000000;"> Sender: TObject;
<span style="color: #0000ff;">const<span style="color: #000000;"> AItem: TListViewItem); <span style="color: #0000ff;">var<span style="color: #000000;"> R: TRectF; <span style="color: #0000ff;">begin <span style="color: #0000ff;">if (AItem.Objects.DetailObject <> <span style="color: #0000ff;">nil) <span style="color: #0000ff;">and<span style="color: #000000;"> (AItem.Objects.DetailObject.Text <> <span style="color: #800000;">'') <span style="color: #0000ff;">then <span style="color: #0000ff;">begin <span style="color: #008000;">//<span style="color: #008000;"> 计算文字显示的区域 R := RectF(<span style="color: #800080;">0,<span style="color: #800080;">0,AItem.Objects.DetailObject.Width,<span style="color: #800080;">10000<span style="color: #000000;">); ListView1.Canvas.MeasureText(R,AItem.Objects.DetailObject.Text,AItem.Objects.DetailObject.WordWrap,[],TTextAlign.Leading,TTextAlign.Leading);
<span style="color: #0000ff;">end;
补充:计算最后一项区域并卷到最后一项 = ListView1.GetItemRect(ListView1.Items.Count - );
ListView1.ScrollViewPos := R.Bottom;
;
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |