Текущий архив: 2003.11.17;
Скачать: CL | DM;
ВнизStringGrid Найти похожие ветки
← →
Nikolas (2003-11-06 20:38) [0]Друзья программеры, если не трудно, подскажите, как в StringGrid сделать сетку другого цвета? И как в этом компоненте сделать цвет шрифта в определенной ячейке допустим красного цвета при этом цвет остальных скажем - зеленый.
← →
Mike_Goblin (2003-11-06 21:10) [1]Цитата из Help
OnDrawCell
Occurs when a cell in the grid needs to be drawn.
type
TDrawCellEvent = procedure (Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState) of object;
property OnDrawCell: TDrawCellEvent;
Description
Write an OnDrawCell event handler to draw the contents of all the cells in the grid. Draw on the cell using the methods of the Canvas property. The Rect parameter indicates the location of the cell on the canvas. The Col and Row parameters indicate the column and row indexes of the cell that should be drawn. The State parameter indicates whether the cell has input focus, whether the cell is selected, and whether the cell is a fixed (nonscrolling) cell.
If the OnDrawCell event handler is not assigned, all cells in the draw grid will appear empty. If the DefaultDrawing property is True, the draw grid paints the background color of the cell before the OnDrawCell event, and draws a focus rectangle around the selected cell after the OnDrawCell event handler finishes drawing the contents of the cell. If the DefaultDrawing property is False, the OnDrawCell event handler should paint the background of the cell and provide all visual indication of selection and focus.
← →
Александр из Минска (2003-11-07 14:56) [2]procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if gdFixed in State then Exit;
case ACol of
1 :
begin
StringGrid1.Canvas.Brush.Color := clGreen;
StringGrid1.Canvas.Brush.Style := bsSolid;
StringGrid1.Canvas.FillRect(Rect);
end;
2 :
begin
StringGrid1.Canvas.Brush.Color := clBlue;
StringGrid1.Canvas.Brush.Style := bsSolid;
StringGrid1.Canvas.FillRect(Rect);
end;
3 :
begin
StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.Brush.Style := bsSolid;
StringGrid1.Canvas.FillRect(Rect);
end;
end;
if gdSelected in State then
begin
StringGrid1.Canvas.Brush.Color:= clHighLight;
StringGrid1.Canvas.Font.Color := clHighLightText;
end;
StringGrid1.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, StringGrid1.Cells[ACol, ARow]);
end;
Страницы: 1 вся ветка
Текущий архив: 2003.11.17;
Скачать: CL | DM;
Память: 0.44 MB
Время: 0.009 c