I can confirm this behavior. Technically, its correct. Since a
TValueListEditor is based on
TCustomStringGrid, which always requires at lease one row.
InsertRow() checks to see if there is an empty row available, and if so, it simply replaces the values. So, "Technically", no new row had been inserted.
I can't see this behavior being changed since it is defined in
TCustomDrawGrid, so a change in behavior would effect all components derived from
TCustomDrawGrid.
I'd say you have a couple of choices: Write a utility function to add items, which would detect when a new row is added, but the
RowCount doesn't change.
procedure ValueListEditorAppendRow(AValueListEditor: TValueListEditor; const AName, AValue: string);
var
LRowCount: integer;
begin
LRowCount := AValueListEditor.RowCount;
AValueListEditor.InsertRow(AName, AValue, True);
if Assigned(AValueListEditor.OnColRowInserted) and (LRowCount = AValueListEditor.RowCount) then begin
AValueListEditor.OnColRowInserted(AValueListEditor, False, 1, 1); // Manually trigger notification event
end;
end;
A quick look at the Delphi docs, show
OnColRowInserted is not supported.
https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.ValEdit.TValueListEditor_EventsWhich means, there is most likely a better way to handle your requirements. Maybe:
OnStringsChanging?
OnValidateEntry seems to work on first inserts.