Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.02.18;
Скачать: CL | DM;

Вниз

Как в RXDBGrid текущию строку сделать с другим Font или цветом?   Найти похожие ветки 

 
Fran   (2002-01-24 09:59) [0]

Как в RXDBGrid текущию строку сделать с другим Font или цветом?
Т.е. строку где стоит курсор.


 
savva   (2002-01-24 10:01) [1]

а перерисовывать самостоятельно не пробовал?


 
gek   (2002-01-24 10:10) [2]


procedure TForm_find.RxDBGrid_findGetCellParams(Sender: TObject; Field: TField;
AFont: TFont; var Background: TColor; Highlight: Boolean);
begin
if(Highlight)and(RxDBGrid_find.Focused) then
begin
AFont.Color := clHighlightText;
Background := clHighlight;
end
else if(Highlight)and( not RxDBGrid_find.Focused)then
begin
AFont.Color := clnavy;
Background := clbtnface;
end;
end;


 
Alexandr   (2002-01-24 10:29) [3]

это по-моему для только для текущей ячейки, а для все текущей строки надо по-другому


 
Alexandr   (2002-01-24 10:29) [4]

кстати, в кулибе написано как делать


 
savva   (2002-01-24 10:47) [5]

Delphi Help ©
The following example conditionally changes the font color of rows in a DB Grid. The following code is added to the DB Grid’s OnDrawDataCell event. If the field Size is greater than 10, the row’s font will be red.

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);

begin
if Table1.FieldByName("Size").AsFloat > 10 then
DBGrid1.Canvas.Font.Color := clRed;
DBGrid1.DefaultDrawDataCell(Rect, Field, State);
end;

надо привязываться к State:

Description

TGridDrawState represents state information about the cell of a grid that is being rendered. It is a set that includes 0 or more of the following:

Value Meaning

gdSelected The cell is currently selected.
gdFocused The cell has input focus.
gdFixed The cell is in the fixed region of the grid.

то есть тебе надо gdFocused - и все...


 
savva   (2002-01-24 10:51) [6]

а что бу перерисовать все строку - ИМХО просто пройтись по горизонтали от 1 столбца к последнему...


 
Alexandr   (2002-01-24 11:02) [7]

вот что в кулибе написано по поводу выделения цветом всей текущей строки


DefaultDrawing:=False;
....
procedure TfrmCard.GridDrawColumnCell(Sender: TObject; constRect: TRect;

DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var

Index : Integer;
Marked, Selected: Boolean;
begin


Marked := False;
if (dgMultiSelect in Grid.Options) and THackDBGrid(Grid).Datalink.Active then
Marked:=Grid.SelectedRows.Find(THackDBGrid(Grid).Datalink.Datasource.Dataset.Bookmark,Index);


Selected := THackDBGrid(Grid).Datalink.Active and (Grid.Row-1 = THackDBGrid(Grid).Datalink.ActiveRecord);


if Marked then
begin
Grid.Canvas.Brush.Color:=$DFEFDF;
Grid.Canvas.Font.Color :=clBlack;
end;


if Selected then
begin
Grid.Canvas.Brush.Color:=$FFFBF0;
Grid.Canvas.Font.Color :=clBlack;
if Marked then
Grid.Canvas.Brush.Color:=$EFE3DF; { $8F8A30 }
end;


Grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

где



--------------------------------------------------------------------------------
THackDBGrid = class(TDBGrid)

property DataLink;
property UpdateLock;
end;

Обратите внимание на обьявление класса THackDBGrid. Таким образом можно получить доступ к приватным полям, свойствам и методам класса, что, к сожалению, приходится делать, если авторы исходного класса оказались не предусмотрительны. [001138




 
Fran   (2002-01-24 15:48) [8]

Спасибо, последний совет Alexandr (24.01.02 11:02) самый правильный. Все получилось. А в Кулибе я этого аочему-то не нашел :(



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

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

Наверх




Память: 0.49 MB
Время: 0.014 c
14-57207
McSimm
2001-12-27 16:45
2002.02.18
Мне понравилось:


1-57124
Demon Ltd
2002-02-03 00:49
2002.02.18
Разница между датами


14-57191
dido
2001-12-28 09:09
2002.02.18
Хочу совет


7-57232
Zevsus
2001-11-13 00:28
2002.02.18
Запускаем процесс, идем его завершения или сворачивания и обрабатываем сие событие..


14-57211
Serg!
2001-12-29 12:15
2002.02.18
Сколько может стоить?