gpt4 book ai didi

delphi - 当 GroupView 处于事件状态时,向 TListView 添加或插入项目总是将其添加到末尾

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

在德尔福 2009 中:

当 TListView 的 GroupView 处于事件状态时,向 TListView 添加或插入项目总是将其添加到列表的末尾,无论参数指定的索引如何。当 GroupView 设置为 false 时,它​​会将其添加到指定的索引处。但当它是真的时,这种行为就不会被看到。

ListView2.Items.Insert(1)

上面应该在指定的索引“1”处插入项目,但始终将其添加到列表的末尾。我在这里做错了什么?

object ListView2: TListView
Left = 32
Top = 40
Width = 161
Height = 233
BorderWidth = 5
Columns = <
item
AutoSize = True
end>
DoubleBuffered = False
FlatScrollBars = True
Groups = <
item
Header = 'test'
Footer = 'aksdlkajsd;flkj'
GroupID = 0
State = [lgsNormal]
HeaderAlign = taLeftJustify
FooterAlign = taLeftJustify
Subtitle = 'adgasdfasdf'
TopDescription = 'test desc'
BottomDescription = 'adsfasdfasdf'
TitleImage = 0
ExtendedImage = 0
end
item
Header = 'test1'
GroupID = 1
State = [lgsNormal]
HeaderAlign = taLeftJustify
FooterAlign = taLeftJustify
TopDescription = 'test1 desc'
TitleImage = 1
ExtendedImage = 1
end>
HideSelection = False
IconOptions.WrapText = False
Items.ItemData = {
03D80000000500000000000000FFFFFFFFFFFFFFFF0000000000000000000000
0003740077006F00FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000
086100730064006600610073006400660000000000FFFFFFFFFFFFFFFF000000
000000000000000000057400680072006500650000000000FFFFFFFFFFFFFFFF
000000000000000000000000036F006E00650000000000FFFFFFFFFFFFFFFF00
00000000000000000000001866006F0075007200320033003300330033003300
33003300330033003300330033003300330033003300330033003300}
MultiSelect = True
GroupView = True
ParentDoubleBuffered = False
ShowColumnHeaders = False
TabOrder = 0
ViewStyle = vsReport

结束

以及添加项目@索引0的代码

procedure TForm1.Button1Click(Sender: TObject);
var
oListItem: TListItem;
begin
oListItem := ListView2.Items.Insert(0);
oListItem.Caption := 'CCCCCCCC';
oListItem.GroupID := 0;
end;

谢谢和问候,帕万。

最佳答案

这可能取决于您更改的其他属性(例如 SortType)。
我尝试使用一个简单的文本列表(使用 ViewStyle =vsList),无论是否设置了 GroupView,它都会插入到指定的索引处:

  object ListView1: TListView
Left = 24
Top = 16
Width = 250
Height = 150
Columns = <>
Items.ItemData = {
03480000000200000000000000FFFFFFFFFFFFFFFF00000000FFFFFFFF000000
00057400650073007400310000000000FFFFFFFFFFFFFFFF00000000FFFFFFFF
000000000574006500730074003200}
GroupView = True
TabOrder = 0
ViewStyle = vsList
end

procedure TForm1.Button1Click(Sender: TObject);
begin
ListView1.Items.Insert(1).Caption := Edit1.Text;
end;

关于delphi - 当 GroupView 处于事件状态时,向 TListView 添加或插入项目总是将其添加到末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1076861/

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