Главная страница
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.018 c
14-56843
VID
2003-10-28 13:00
2003.11.17
Админинг Windows 2000 (лок. машина)


3-56508
froland
2003-10-28 08:27
2003.11.17
Сумма поля


1-56721
RoLeX
2003-11-06 20:49
2003.11.17
Как написать следующее условие: если X не равен Edit2.text, то...


8-56779
Hatawa
2003-07-20 18:17
2003.11.17
Почему StretchBlt при использовании портит рисунок?


14-56810
Карелин Артем
2003-10-24 14:47
2003.11.17
Посоветуйте систему контроля версий. Дельфи.