TcxCustomGridTableView.OnGetScrollbarAnnotationHint Event
Enables you to show hints for scrollbar annotations.
Declaration
property OnGetScrollbarAnnotationHint: TcxGridGetScrollbarAnnotationHint read; write;
Remarks
This event occurs every time the mouse pointer enters into the area occupied by one or more scrollbar annotation marks. Handle the OnGetScrollbarAnnotationHint event to display a hint for one or more of the triggered annotation marks. For example, the following code example shows a hint for the three custom scrollbar annotations and the predefined error annotation:
procedure TMyForm.cxGrid1DBTableView1GetScrollbarAnnotationHint(Sender: TcxCustomGridTableView; AScrollbarAnnotationRows: TdxScrollbarAnnotationRowIndexLists; var AHint: string);
function GetValue(ARecordIndex: Integer; AColumn: TcxGridDBColumn): Variant; // Obtains the specified cell value
begin
Result := cxGrid1DBTableView1.ViewData.Records[ARecordIndex].Values[AColumn.Index];
end;
var
AKind: TdxScrollbarAnnotationKind;
AList: TdxScrollbarAnnotationRowIndexList;
I: Integer;
ACount: Integer;
AAnnotationHint: string;
begin
for AKind in AScrollbarAnnotationRows.Keys do // Iterates through all annotations that require a hint
begin
AList := AScrollbarAnnotationRows[AKind];
ACount := Min(5, AList.Count); // The number of processed scrollbar annotation marks is 5 or the number of triggered marks, whichever is less
for I := 0 to ACount - 1 do // Iterates through all scrollbar annotation marks to be processed
begin
case AKind of
0: // If the mouse pointer enters into the area occupied by a mark of the first custom scrollbar annotation
begin
AAnnotationHint := Format('(%s doors)', [IntToStr(GetValue(AList[I], clDoorCount))]);
end;
1: // If the mouse pointer enters into the area occupied by a mark of the second custom scrollbar annotation
begin
AAnnotationHint := Format('(price: %s)', [FormatFloat('$,0;($,0)', GetValue(AList[I], clPrice))]);
end;
2: // If the mouse pointer enters into the area occupied by a mark of the third custom scrollbar annotation
begin
AAnnotationHint := Format('(%s cylinders)', [IntToStr(GetValue(AList[I], clCylinderCount))]);
end;
dxErrorScrollbarAnnotationID: // If the mouse pointer enters into the area occupied by a mark of the predefined error scrollbar annotation
begin
AAnnotationHint := '(MPG City is not specified!)';
end;
else // If a scrollbar annotation requires no hint
AAnnotationHint := ''; // Assigns an empty string as a base hint
end;
if AAnnotationHint <> '' then // If the scrollbar annotation mark has a base hint
begin // Expands the base hint with content of the corresponding grid row
AAnnotationHint := Format('%s %s ', [GetValue(AList[I], clName), GetValue(AList[I], clModification)]) + AAnnotationHint;
AHint := AHint + IfThen(AHint <> '', dxCRLF) + AAnnotationHint;
end;
end;
if AList.Count > ACount then // If the list of hinted annotation marks is too large
AHint := AHint + dxCRLF + Format('...and %d more car(s)', [AList.Count - ACount]); // Truncates the list
end;
end;
Refer to the TcxGridGetScrollbarAnnotationHint procedural type description for detailed information on parameters accessible within an OnGetScrollbarAnnotationHint event handler.
See Also