Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Как в RXDBGrid текущию строку сделать с другим Font или цветом? [D5, IB6.x, ]


Fran ©   (2002-01-24 09:59:00) 

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


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

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


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

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


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



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

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


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

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 - и все...


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

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


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

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


gek   (2002-01-24 10:10:00) [7]


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;


savva   (2002-01-24 10:01:00) [8]

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


Наверх

Титульная страница Поиск, карта сайта Написать письмо