Example 86 : Using the TAdvGridLookupBar

vcl grid loopupbar

The TAdvGridLookupBar offers an easy to use alphabetical or categorical lookup bar that can be shown on the left or right side of the grid. In its easiest configuration, the TAdvGridLookupBar retrieves the alphabetical lookup information automatically from the assigned grid column. The lookup highlights in the alphabet or categories for which items data is available in the grid and when clicked, automatically moves the focus to the first item belonging to the clicked letter or category.

Using TAdvGridLookupBar with alphabetic lookup
Drop the TAdvGridLookupBar on the form next to a TAdvStringGrid. Assign the grid to AdvGridLookupBar.Grid and set the column from where the lookup items need to be retrieved.

In code, loading the grid and initializing the lookup bar is done with:
  AdvStringGrid1.SaveFixedCells := false;
  AdvStringGrid1.SortSettings.Column := 1;

  AdvGridLookupBar1.Grid := AdvStringGrid1;
  AdvGridLookupBar1.Column := 1;

Using TAdvGridLookupBar with custom category lookup
vcl grid lookupbar

When AdvGridLookupBar.CategoryType is set to Custom, the lookupbar is filled with categories as defined in the collection AdvGridLookupBar.Categories. Each category has a display text, a lookup text and a Tag that holds the grid record number where the first entry matching the category is found. Optionally, an imagelist image can be used as well and this is configured with the category ImageIndex.
This sample code snippet shows how to initialize the lookup with the 12 months of the year as category and with the category text rotated in the lookupbar:
  i: integer;
  AdvGridLookupBar1.CategoryType := custom;
  AdvGridLookupBar1.Rotated := true;

  for i := 1 to 12 do
  with AdvGridLookupBar1.Categories.Add do
    Text := ShortMonthNames[i];
    Tag := GetGridRowOfMonth(i);

When a category is clicked, the grid focus row is set to the row defined in the category tag. Simultanously, when the active row in the grid changes, the category that matches the row is highlighted.
Important note: it is important that the categories are added in the sequence of increasing row numbers.

Delphi project & source files for downloading included in the main demos distribution for Delphi