delphi
stringgrid의 특정 셀의 색상을 변경하는 코드
openheart
2023. 3. 8. 20:43
반응형
SMALL
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
Grid: TStringGrid;
begin
Grid := Sender as TStringGrid;
// Set color for cell in row 2 and column 3
if (ACol = 3) and (ARow = 2) then
begin
Grid.Canvas.Brush.Color := clRed;
Grid.Canvas.FillRect(Rect);
end;
// Draw cell contents
Grid.Canvas.Font := Grid.Font;
Grid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Grid.Cells[ACol, ARow]);
end;
반응형
LIST