Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.015 c
14-56830
Vlad Oshin
2003-10-28 09:13
2003.11.17
Составим наш ответ Чемберлену?


3-56443
Kinder
2003-10-29 18:21
2003.11.17
BLOB в Access


3-56459
DimChan
2003-10-29 09:12
2003.11.17
AccessViolation


14-56901
aga
2003-10-25 16:55
2003.11.17
NSIS


6-56801
ilka
2003-09-22 16:30
2003.11.17
откуда ошибка (TIdTcpServer TIdTcpClient)




   Наверх