Вниз
Скачать: CL | DM;

StringGrid   Найти похожие ветки 

 
irmantukas ©   (2002-11-06 00:54) [0]

Привет всем. Просветите мою голову про StringGrid. Скажем с кликом мышки я вибираю какую то cell. Как сделать чтоб после клика это cell поменила цвет.


 
¤NoNaMe¤ ©   (2002-11-06 01:13) [1]

Обработать OnDrawCell


 
irmantukas ©   (2002-11-06 01:33) [2]

Пример можно?


 
MBo ©   (2002-11-06 06:20) [3]

пример есть в хелпе по OnDrawCell, надо только, вероятно, учитывать State (выбранная ли ячейка)


 
Separator ©   (2002-11-06 06:24) [4]

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Cl: TColor;

begin
if gdFocused in State then
with (Sender as TStringGrid).Canvas do
begin
Cl:= Brush.Color;
Brush.Color:= clGreen;
FillRect(Rect);
Brush.Color:= Cl;
Cl:= Font.Color;
Font.Color:= clBlue;
TextOut(Rect.Left, Rect.Top, (Sender as TStringGrid).Cells[ACol, ARow]);
Font.Color:= Cl;
end;
end;


 
irmantukas ©   (2002-11-06 15:09) [5]

Как сделать, чтоб цвет зафиксировался. Когда я выхожу из cell, цвет проподает.


 
KoluChi ©   (2002-11-06 15:29) [6]

Весь код не стал приводить, главное идея:
RCell = record
Col, Row: Integer;
end;
PCell = ^RCell;
TCellList = TList; //List of PCell
function InCellList(ACellList: TCellList; ARow, ACol: Integer): Boolean;
procedure CellListAdd(ACellList: TCellList; ARow, ACol: Integer);
procedure CellListDel(ACellList: TCellList; ARow, ACol: Integer);
//-------------------------------------------
var CellList: TCellList;
//--------------------------------------------
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
Cl: TColor;

begin
if (gdFocused in State) or InCellList(CellList, ARow, ACol) then
with (Sender as TStringGrid).Canvas do
begin
if not InCellList(CellList, ARow, ACol) then
CellListAdd(CellList, ARow, ACol)
else
CellListDel(CellList, ARow, ACol);
Cl:= Brush.Color;
Brush.Color:= clGreen;
FillRect(Rect);
Brush.Color:= Cl;
Cl:= Font.Color;
Font.Color:= clBlue;
TextOut(Rect.Left, Rect.Top, (Sender as TStringGrid).Cells[ACol, ARow]);
Font.Color:= Cl;
end;
end;






Страницы: 1 вся ветка

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



Память: 0.46 MB
Время: 0.013 c
1-59256
kosdem
2002-11-04 08:22
2002.11.18
Сlock


3-59055
KAA
2002-10-29 15:17
2002.11.18
2000 Запуск хранимой процедуры по таймеру.


1-59231
Sers
2002-11-06 12:39
2002.11.18
Virtual and dynamic methods


7-59441
Maxi-mov
2002-09-15 13:36
2002.11.18
Как можно


1-59208
vixic
2002-11-06 14:33
2002.11.18
Строки!




   Наверх