Главная страница
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.48 MB
Время: 0.029 c
1-59125
Gayrus
2002-11-07 11:45
2002.11.18
mp3


3-59020
RedKat
2002-10-28 17:47
2002.11.18
Большой цикл с запросами к БД Access


7-59458
antonioxxx
2002-09-16 23:21
2002.11.18
Работа с датой


1-59271
Новачок
2002-11-07 13:29
2002.11.18
Простой вопрос


1-59281
TankMan
2002-11-05 17:00
2002.11.18
Сразу менять курсор...