Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 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.47 MB
Время: 0.025 c
1-56597
scorpi
2003-11-06 07:56
2003.11.17
Считывание координат с Формы


11-56543
centromix
2003-02-20 13:19
2003.11.17
Обновление кол


14-56861
Semas
2003-10-27 11:48
2003.11.17
basic интерпритация


1-56564
Oleg_
2003-11-06 13:18
2003.11.17
Как определить ширину Canvas.TextOut


1-56568
RoLeX
2003-11-07 21:36
2003.11.17
Как узнать местонахождение папки Temp ???