Autor Beitrag
Hendrik
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324



BeitragVerfasst: Fr 30.04.04 16:04 
Hi!


Wie kann ich denn in einem DBGrid nur eine bestimmte Spalte, also nicht die komplette Zeile, einfärben? Ich hatte hiernach zwar schon gesucht, bin aber auf kein resultet gekommen...
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Sa 01.05.04 16:31 
Hi,

so kannst Du die Spalten unterschiedlich einfärben:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin

  if DataCol=0 //z.B. erste Spalte
   then DBGrid1.Canvas.Brush.Color:=clRed
   else DBGrid1.Canvas.Brush.Color:=clYellow;

  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);

end;


Gruß, jjturbo

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Hendrik Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324



BeitragVerfasst: Sa 01.05.04 22:12 
Super! Danke!