响应DrawCell事件
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (gdSelected in State) then
begin
...
end;
end;
TGridDrawState represents information that is useful when rendering the cell of a grid.UnitClassestype TGridDrawState = set of (gdSelected, gdFocused, gdFixed);DescriptionTGridDrawState represents state information about the cell of a grid that is being rendered. It is a set that includes 0 or more of the following:Value MeaninggdSelected The cell is currently selected.
gdFocused The cell has input focus.
gdFixed The cell is in the fixed region of the grid.
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (gdSelected in State) then
begin
...
end;
end;
TGridDrawState represents information that is useful when rendering the cell of a grid.UnitClassestype TGridDrawState = set of (gdSelected, gdFocused, gdFixed);DescriptionTGridDrawState represents state information about the cell of a grid that is being rendered. It is a set that includes 0 or more of the following:Value MeaninggdSelected The cell is currently selected.
gdFocused The cell has input focus.
gdFixed The cell is in the fixed region of the grid.
begin
caption:= inttostr(StringGrid1.Row)+'-'+inttostr(Stringgrid1.Col);
end;在标题栏可以看到鼠标点中的cell的行和列。