Einzelnen Beitrag anzeigen

Robert_G
(Gast)

n/a Beiträge
 
#5

Re: Datensätze im DBGrid farbig hinterlegen!

  Alt 11. Feb 2004, 16:57
Einfach mal im OI in das Event klicken und die Zaubertaste drücken...
Zitat von Delphi OH:
Note: If the Columns property has a State property of csDefault, the OnDrawDataCell event occurs before the OnDrawColumnCell. The OnDrawDataCell event is obsolete, and only included for backward compatibility. Do not set both an OnDrawDataCell event handler and an OnDrawColumnCell event handler.

Kleines Beispiel:
Es färbt eine Spalte rot. Ausgewählte Zellen dieser Spalte sind orange.

Delphi-Quellcode:
  With DBGrid1.Canvas Do
  Begin
    If Column.Index = 2 Then
    Begin
      If gdSelected In state Then
        Brush.Color := $000080FF
      Else
        Brush.Color := clRed;
    End
    Else
    Begin
      If gdSelected In state Then
        Brush.Color := $00EFD3C6
      Else
        Brush.Color := clWhite;
    End;
    Font.Color := clBlack;
  End;

  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, state);
Nachtrag:
Ich hatte mich verguckt und OnDrawDataCell benutzt -> korrigiert.
Ausrede: Ich benutze kein DBGrid
  Mit Zitat antworten Zitat