Hi,
In Delphi 2009 :
When TListView's GroupView is Active, adding or inserting an item to a TListView always adds it to the end of the list, regardless of Index specified as param. When GroupView is set to false it adds it at the specified index. But when it is true, this behavior is not seen.
ListView2.Items.Insert(1)
The above should insert item at the sepecified index "1", but always adds it to the end of the list. What am I doing wrong here?
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
end
and Code to add item @ index 0
procedure TForm1.Button1Click(Sender: TObject);
var
oListItem: TListItem;
begin
oListItem := ListView2.Items.Insert(0);
oListItem.Caption := 'CCCCCCCC';
oListItem.GroupID := 0;
end;
Thanks & Regards, Pavan.