TInspectorBar and seach item by name or tag

Hi

With AdvColumnGrid, it is possible to find a specific column using function ColumnByTag or ColumnByName. There is an equivalent for TInspectorBar component ?

Regards

Olivier

The only method that exists, is to find an item based on item.ID:

Inspectorbar.Panels.Items.FindItemID(ItemID)

Hi,

Unfortunatly, it is not exactly what I expected.

So, I created 2 functions in order to find the Items :

One with OUT variables, and one without.

I build also 2 others in order to find an item by its name

FUNCTION TfDivers.InspectorByTag(
CONST lInspector : TInspectorBar;
CONSt lTag : Integer;
OUT lPanel, lItem : Integer)
: TInspectorItem;
VAR
I, J : Integer;

PROCEDURE Succes();
BEGIN
    lPanel := I;
    lItem := J;
    result := lInspector.Panels[I].Items[J];
END; // Fin de Procedure

BEGIN
  TRY
    result := Nil;
    lPanel := -1;
    lItem := -1;
    lInspector.BeginUpdate;
    TRY
       IF lTag <> 0 THEN
       BEGIN
           FOR I := 0 TO lInspector.Panels.Count - 1 DO
           BEGIN
              FOR J := 0 TO lInspector.Panels[I].Items.Count - 1 DO
              BEGIN
                 IF lTag = lInspector.Panels[I].Items[J].Tag THEN
                 BEGIN
                    Succes;
                    Break;
                 END; // Fin de IF
              END; // Fin de FOR
              IF Assigned( result ) THEN
                 Break;
          END; // Fin de FOR
       END; // Fin de IF
    EXCEPT
         ON E : SysUtils.Exception DO
         BEGIN
            result := Nil;
            RAISE;
         END;
    END; // Fin de EXCEPT
  FINALLY
    lInspector.EndUpdate;
  END; // Fin de FINALLY
END; // Fin de FUNCTION

If it is critical you store the identifier in the InspectorItem.Tag, then indeed, a different function is needed.
We'll add two functions for this in the next release

  • function ItemByTag(ATag: integer; APanel: TInspectorPanel = nil): TInspectorItem
  • function PanelByTag(ATag: integer): TInspectorPanel

Yes, it. So it should be great :+1: