|
How to use TCommonInspector?
In first, the ItemCount property must be set. You can change this property at design time by Delphi's Object Inspector and at runtime from your code.
To use TCommonInspector you have to create handlers at least for 3 events:
OnGetName - this event must return the property name
OnGetValue - this event must return the property value
OnSetValue - this event must set the property value
TheIndex passed to each event is index of the item that must be processed, TheIndex for the first item is 0.
var
// values list, use your own data instead
UserValues: array[0..9] of string;
...
procedure TForm1.CommonInspector1GetName(Sender: TObject;
TheIndex: Integer; var Value: String);
begin
Value:='Property name #'+IntToStr(TheIndex);
end;
procedure TForm1.CommonInspector1GetValue(Sender: TObject;
TheIndex: Integer; var Value: String);
begin
Value:=UserValues[TheIndex];
end;
procedure TForm1.CommonInspector1SetValue(Sender: TObject;
TheIndex: Integer; const Value: String);
begin
UserValues[TheIndex]:=Value;
end;
By default the value is changed (and the OnSetValue is fired) only if the user pressed the Enter key after editing, but this can be changed by OnGetAutoApply event - just change the passed Value to True and the value will be set when user leaves the edited item:
procedure TForm1.CommonInspector1GetAutoApply(Sender: TObject;
TheIndex: Integer; var Value: Boolean);
begin
Value:=True;
end;
|