gpt4 book ai didi

delphi - 如何跳过一列并将字符串添加到 ListView 中的另一列?

转载 作者:行者123 更新时间:2023-12-02 15:03:39 25 4
gpt4 key购买 nike

我们创建一个包含 5 列的 ListView 。在一个函数中,我们按顺序在前 3 列中添加数据。在第二个函数中,我们要将字符串添加到第五列。在第二个功能之前,第 4 列可以为空白或已填充。我们只想跳过该列并在第五列中添加数据。或者问题可以归结为检查第四列的值。如何检查呢?我们尝试了if listview.items[i].SubItems.Strings[2]=''..., 会提示越界。

请大家给点建议。预先感谢您。

最佳答案

您无法跳过 TListView 中的一列当您使用 item.SubItems 属性时,但您可以将空字符串分配给列。

您必须像这样继续:

当您添加新的 TItemList 时,请务必先填充您的列.

item:=listview.Items.Add();
item.captiom:='Data col1';
item.SubItems.Add('Data col2');
item.SubItems.Add('Data col3');
item.SubItems.Add('');//empty
item.SubItems.Add('');//empty

然后在其他函数中,访问任意列以检查它是否为空或是否要添加数据。

 if listview.Items.Item[0].SubItems[2]<>'' then //check if the fourth column of the listiew is empty
listview.Items.Item[0].SubItems[2]:='Data col4' //adding the data

关于delphi - 如何跳过一列并将字符串添加到 ListView 中的另一列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4107082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com