Tips and Frequently Asked Questions
Associating a unique ID with search list items for TAdvSearchEdit used in TAdvStringGrid
When a TAdvSearchEdit is used as inplace editor in the grid via TAdvSearchEditEditLink, it is often desirable to have associated an unique ID with each item in the searchedit and retrieve this ID upon selection.
The following code demonstrates this for a TAdvSearchEdit used as inplace editor where the unique ID is set via the SearchListItem.Tag property and retrieved when editing ends in the grid.OnCellValidate event:
procedure TForm1.FormCreate(Sender: TObject); var si: TSearchListItem; begin // initialize the search edit AdvSearchEditEditLink1.Columns.Add; AdvSearchEditEditLink1.CategoryButton.Visible := false; AdvSearchEditEditLink1.SearchButton.Visible := false; // tag holds the unique value si := AdvSearchEditEditLink1.Items.Add; si.Captions[0] := ''BMW''; si.Tag := 1; si := AdvSearchEditEditLink1.Items.Add; si.Captions[0] := ''Mercedes''; si.Tag := 2; si := AdvSearchEditEditLink1.Items.Add; si.Captions[0] := ''Audi''; si.Tag := 3; end; // use the OnGetEditorType event to specify the TAdvSearchEditEditLink as inplace editor: procedure TForm1.AdvStringGrid1GetEditorType(Sender: TObject; ACol, ARow: Integer; var AEditor: TEditorType); begin AEditor := edCustom; AdvStringGrid1.EditLink := AdvSearchEditEditLink1; end; // retrieve the unique ID of the selected item in the OnCellValidate event: procedure TForm1.AdvStringGrid1CellValidate(Sender: TObject; ACol, ARow: Integer; var Value: string; var Valid: Boolean); var index,t: integer; begin index := (AdvSearchEditEditLink1.GetEditControl as TAdvSearchEdit).SearchList.ItemIndex; t := (AdvSearchEditEditLink1.GetEditControl as TAdvSearchEdit).Items[index].Tag; // the t variable holds the unique ID of the selected item via the TAdvSearchEdit end;
Pricing
Single Developer License
Small Team License
Site License
TMS VCL UI Pack
€ 375
€
150
yearly renewal
license for 1 developer
MOST POPULAR
BEST VALUE
All prices excl. VAT. Renewal price is subject to change and only valid up to 30 days after license has expired. After renewal period a discount price is offered to renew the license.
Free Trial
Note that the TMS VCL UI Pack replaces the TMS Component Pack. Both products can't be installed simultaneously. Therefore TMS Component Pack must first be uninstalled before installing the TMS VCL UI Pack