Sometimes what I perceive as a bug turns out to be ignorance on my part about the component.
I've been using TValueListEditor quite extensively and I've encountered two use cases that _seem_ to be bugs. I've included a small project to illustrate them. Before I think about logging them as bugs, I wanted your take a look
Use Case 1: Order of
RowCount := 0 and
FixedRows := 0 matters.
Drop a TListViewEditor on a form and rename it to
VLE. Drop a button and inside the OnClick event of the button write the following code: Alternatively, you can run the supplied program.
Procedure TForm1.btn_BugFixedCountClick(Sender: TObject);
Begin
With VLE do
begin
//If you switch the order of these statements, the bug goes away ...
RowCount := 0;
FixedRows := 0; //<== Triggers an exception: Item Index out of bound.
End;
end;
The code will raise an exception indicating that the index into the internal
TStrings object of
TValueListEditor is out of bound (-1). If you reverse these two statements, the exception goes away. Is that by design?
Use Case 2: The disappearing object.
This use case is a bit more aggravating: add some rows to the value list editor and set the object of the first column to an instance of a class (again see the supplied code). Everything runs well.
Now, Call
TValueListEditor.InsertRow to insert a row. When you do that,
the object of the last populated row vanishes. Please see the associated code.
Am I not using InsertRow the right way?
Thanks for your feedback.