Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.11.18;
Скачать: 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 вся ветка

Текущий архив: 2002.11.18;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.019 c
1-59173
lak
2002-11-08 22:11
2002.11.18
help me :)


14-59346
Сатир
2002-10-28 11:54
2002.11.18
---|Ветка была без названия|---


8-59290
vlsoft
2002-07-26 21:11
2002.11.18
Нужны художники


4-59497
slipper
2002-10-03 19:03
2002.11.18
память под процесс


4-59509
Leon_O
2002-10-07 15:41
2002.11.18
Билинг