Autor Beitrag
AndreM
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

Win2k, WinXP, Suse 10
D7 Ent
BeitragVerfasst: Do 02.07.09 15:02 
Hallo zusammen,
ich habe ein kleines Problem meinen Zeilen in einem JVDBGrid unterschiedliche Formatierungen zuzuweisen.

Grundsätzlich das Formatieren klappt mit diesem Code schon einmal ohne Probleme, jedoch sieht es danach so aus als wenn er in einer Schleife festhängen würde.
Das Grid wird offentlichlich immer neu gezeichnet, mit der Maus läßt sich das Grid nicht mehr ansprechen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TMainForm.JvDBGridDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin

  if JvMemoryData.FieldByName('status').AsString = '' then
  begin
    JvDBGrid.Canvas.Brush.Color := clTeal;
    JvDBGrid.Font.Color := clWindow;
  end
  else
  begin
    JvDBGrid.Canvas.Brush.Color := clWindow;
    JvDBGrid.Font.Color := clBlack;
  end;

  JvDBGrid.DefaultDrawColumnCell(Rect, Datacol, Column, State);
end;


Wenn jedoch nur eine der Zeilen auskommentieren

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TMainForm.JvDBGridDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin

  if JvMemoryData.FieldByName('status').AsString = '' then
  begin
    JvDBGrid.Canvas.Brush.Color := clTeal;
    JvDBGrid.Font.Color := clWindow;
  end
  else
  begin
    JvDBGrid.Canvas.Brush.Color := clWindow;
    //JvDBGrid.Font.Color := clBlack;
  end;

  JvDBGrid.DefaultDrawColumnCell(Rect, Datacol, Column, State);
end;


dann läuft das ganze ohne Probleme durch und ich kann auch Datensätze im Grid markieren.
Hat einer Idee wo mein Denkfehler liegen könnte?

EDIT: OK, hab mein Fehler selber entdeckt.
Aus "JvDBGrid.Font.Color" mache "JvDBGrid.Canvas.Font.Color" und alles wird gut. :D