I have the following code that produces an EListError when sorting DBSectionlistBox but works fine when sorting SectionlistBox. I'm I missing some additional code?
-----------------------------
implementation
{$R *.dfm}
procedure TForm1.LB_BtnClick(Sender: TObject);
begin
SectionListBox1.SortAllSections; //Hdr sorting OK
end;
procedure TForm1.dbLB_BtnClick(Sender: TObject);
begin
DBSectionListBox1.SortAllSections; //Hdr sorting produces EListError
end;
procedure TForm1.FormCreate(Sender: TObject);
Var i: Integer;
Begin
Randomize;
SectionListBox1.Sections.Clear;
SectionListBox1.Clear;
//
DBSectionListBox1.Sections.Clear;
DBSectionListBox1.Clear;
i:= 0;
For i := 0 To 10 Do
Begin
SectionListBox1.Sections.Add.Caption := FormatDateTime('mmm dd, yyyy HH:MM:SS am/pm', Now + RandomRange(5, 365)) + ' - record: ' + IntToStr(i+1) + ' of 101';
SectionListBox1.Sections.Items.SubItems.Text := 'SubItem date:' + #9#9#9#9#9 + DateToStr(Date + i);
SectionListBox1.Sections.Items.SubItems.add('by:' + #9#9#9#9#9 + ' Me');
//
DBSectionListBox1.Sections.Add.Caption := FormatDateTime('mmm dd, yyyy HH:MM:SS am/pm', Now + RandomRange(5, 365)) + ' - record: ' + IntToStr(i+1) + ' of 101';
DBSectionListBox1.Sections.Items.SubItems.Text := 'SubItem date:' + #9#9#9#9#9 + DateToStr(Date + i);
DBSectionListBox1.Sections.Items.SubItems.add('by:' + #9#9#9#9#9 + ' Me');
End;
//---------------------------
//Debugger Exception Notification
//---------------------------
//Project Project1.exe raised exception class EListError with message 'Invalid property value'.
//---------------------------
//Break Continue Help
//---------------------------
//
// TSECTIONLISTBOX component vs 1.9.2.9
//Calling procedure TListSectionCollection.SwapSections(idx1, idx2: Integer);
//line # 3903: ls := TListSection.Create(self);
//recieving constructor TListSection.Create(Collection: TCollection);
//line # 3423 inherited Create(Collection);
End;
I see you're trying to use TDBSectionListBox as a non DB-aware TSectionListBox, i.e. you're not using the Section's datasource. The TDBSectionListBox is designed to be used with a section's datasource. If you do not want to use it with this datasource, we'd suggest to use a TSectionListBox instead.
The code segment was for testing. in another program I'm using the data-aware portion of the DBSectionListBox. when I tried to sort the DB listbox header section it produced the indicated error.
in an effort to see what I was possible doing incorrectly it used both components for testing.
Am I doing something incorrectly?
M
So far I could not reproduce this here. Would it be possible to send some sample source project using a TClientDataSet for example with which we can reproduce this here so we can investigate?