如何以编程方式添加ListBoxItem?
我只能通过单击组件 – > 项目编辑器找到如何创建ListBoxItem
。
我们如何使用Firemonkey
编程方式创建ListBoxItem
?
假设ListBoxItem
是名为ListBox1
的现有TListBox
组件的项,则可以像这样添加项:
ListBox1.Items.Add('an item name');
替代:
var id: Integer; . . . ListBox1.Items.AddObject('an item name', TObject(id));
编辑请注意,只有在未对基础列表进行排序时,才必须认为此方法有效。
只需创建列表框项,然后将其添加到列表框中:
var ListBoxItem: TListBoxItem; begin ListBoxItem := TListBoxItem.Create(ListBox1); ListBoxItem.Text := 'foo'; // set other properties of the list box item at this point ListBox1.AddObject(ListBoxItem); end;
您还可以使用:
var aItem: TListViewItem; begin for i := 0 to 10 do begin aItem := ListView1.Items.Add; aItem.Text := 'Item Text'; // you can set properties in here.. end; end;
- cordova-ionic ngCordova ios或iPhone文件读取错误代码5 ENCODING_ERR
- Firebase RealtimeDatabase现在不工作?
- cordova手机使用应用程序中的外部网页,同时保持页眉/页脚(导航)
- 尽pipe访问了正确的广告代码,但Google DFP广告素材会随机展示
- 从相机中dynamic检测不同形状(圆形,方形和矩形)?
- 当Toggled和禁用的android开关都显示为灰色
- Phonegap – iOS键盘和下拉“压缩”的Web视图,因为单位
- 如果还使用iOS,则Google Play Services 8.4.0会打破Google Cloud Messaging for Android
- 确定视口或“标准”浏览器的最佳方法