TAdvStringGrid
Example 76 : Balloon functionality in TAdvStringGrid

With this first code snippet, the balloon is set dynamically via the event OnCellBalloon. This event has 3 parameters: ATitle sets the title of the balloon, the AText parameter sets the notes of the balloon and the AIcon sets the icon to display. The icon can have following values:
- 0: no icon
- 1: information icon
- 2: warning icon
- 3: error icon
procedure TForm2.AdvStringGrid1CellBalloon(Sender: TObject; ACol, ARow: Integer; var ATitle, AText: string; var AIcon: Integer); begin if (acol = 1) and (arow = 1) then begin ATitle := 'Hello'; AText := 'I am cell 1,1'; end; end;
A second way to add a balloon for a cell is via the method grid.AddBalloon(). This sample code defines a balloon for cell 2,2 and cell 3,3:
procedure TForm2.FormCreate(Sender: TObject); begin advstringgrid1.AddBalloon(2,2,'Title A','Cell 2,2 is here', biError); advstringgrid1.AddBalloon(3,3,'Title B','Cell 3,3 is here', biWarning); end;
procedure TForm2.AdvStringGrid1CellValidate(Sender: TObject; ACol, ARow: Integer; var Value: string; var Valid: Boolean); begin if length(value) < 3 then begin advstringgrid1.InvalidEntryTitle := 'Input error'; Advstringgrid1.InvalidEntryText := 'Entry not sufficiently long'; Valid := false; end; if length(value) > 5 then begin advstringgrid1.InvalidEntryTitle := 'Input error'; Advstringgrid1.InvalidEntryText := 'Entry is too long'; Valid := false; end; end;