Главная страница
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.018 c
3-59025
DeLz
2002-10-29 18:22
2002.11.18
Может кто знает как в SQL передать параметер для IN (:ParamName)


3-58984
Uran
2002-10-28 12:49
2002.11.18
DBLookupComboBox


3-59016
Youri
2002-10-29 12:53
2002.11.18
Тормозит прога!!!


14-59426
lipskiy
2002-10-17 20:58
2002.11.18
Как в XP запаролить конкретный ресурс (папку)?


3-59062
Ghost-Kasper
2002-10-30 12:13
2002.11.18
Как можно даставать данные из Excel, не преобразовывая их в друго