Вниз
Скачать: CL | DM;

Цветной DBGrid   Найти похожие ветки 

← →
deras   (2007-02-23 15:02) [0]

Читал статью "Разноцветный грид". Вроде понятно... кроме одного. Как задать условие для разрисовки. Например, если в поле "age", значение 10, то текст в строке сделать синим.


← →
Ega23 ©   (2007-02-23 15:08) [1]


procedure TFClassConfig.dbgCOMUnitsGetCellParams(Sender: TObject;
 Column: TColumnEh; AFont: TFont; var Background: TColor;
 State: TGridDrawState);
var
ds:TDataSet;
begin
 if not (Sender is TDBGridEh) then Exit;
 ds:=TDBGridEh(Sender).DataSource.DataSet;
 if ds.IsEmpty then Exit;
 if ANSIUpperCase(Column.FieldName)="COMMSKSTR" then
  begin
   if ds.FieldByName("COMMsk").AsInteger=0 then
      AFont.Color:=clRed
    else
      AFont.Color:=clBlue;
  end;

 if ANSIUpperCase(Column.FieldName)="COMTYPNAM" then
  begin
   Case ds.FieldByName("COMTypCod").AsInteger of
     10 :  AFont.Color:=clGreen;
     20 :  AFont.Color:=clAqua;
     30 :  AFont.Color:=clBlue;
     else  AFont.Color:=clGray;
   end;
  end;

end;


← →
Ученик чародея ©   (2007-02-23 15:08) [2]

DBGrid:
DefaultDrawing=False;
задать обработчик события
OnDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState)

Отрисовка через DbGrid.Canvas


← →
Desdechado ©   (2007-02-23 15:08) [3]

procedure TfrmPortNagr.gridNagrDrawColumnCell( Sender: TObject; const Rect: TRect;
         DataCol: Integer; Column: TColumn; State: TGridDrawState );
begin
 with( gridNagr ) do
   if( Enabled and ( not( gdFocused in State ) ) and
       ( Column.FieldName = "CCONT" ) ) then
     begin
       if( qryPortNagr.FieldByName( "NSTATUS" ).AsInteger = PS_RESERVED ) then
         begin
           Canvas.Brush.Color := clMoneyGreen;
           Canvas.FillRect( Rect );
         end
       else if( qryPortNagr.FieldByName( "NSTATUS" ).AsInteger in [ PS_NOTVALID, PS_EQUIPPED ] ) then
         begin
           Canvas.Brush.Color := clYellow;
           Canvas.FillRect( Rect );
         end;
       DefaultDrawColumnCell( Rect, Column.Index, Column, State );
     end;
end;



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

Скачать: CL | DM;



Память: 0.45 MB
Время: -0.974 c
6-1159346956
DeadMeat
2006-09-27 12:49
2007.03.18
Indy 9 или Indy 10 ?


2-1172231782
rts111
2007-02-23 14:56
2007.03.18
TWordApplication: Как узнать количество страниц в документе?


6-1160052302
Прохожев М
2006-10-05 16:45
2007.03.18
Письма с вложением


2-1172484319
Sid-Max
2007-02-26 13:05
2007.03.18
Протоколирование !!!


15-1172174171
default
2007-02-22 22:56
2007.03.18
Можно-ли спать по 4 часа без потерь для здоровья?




   Наверх