Autor Beitrag
Dee-M-Cee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: So 16.04.06 14:48 
Hallo.
Ich möchte im StringGrid einzelne Zellen Fett schreiben.
Ich benutze die DrawCell Prozedur und wollte eigentlich das ganz simpel so machen:

ausblenden Delphi-Quelltext
1:
Grid_Kal_Monat.Canvas.Font.Style:=fsBold;					


bekomme dann aber folgenden Fehler:

ausblenden Delphi-Quelltext
1:
[Error] Unit1.pas(401): E2010 Incompatible types: 'TFontStyles' and 'TFontStyle'					


Wie muss ich das denn machen ?
bs-Hobbit
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46

Windows Xp (Home/Prof.), Windows Server 2003, Linux
D7,D2005
BeitragVerfasst: So 16.04.06 15:17 
Ganz einfach weil .styles eine Menge ist die du TFontStyle füllen kannst ;)

ausblenden Delphi-Quelltext
1:
Grid_Kal_Monat.Canvas.Font.Style:=Grid_Kal_Monat.Canvas.Font.Style + [fsBold];					


sollte dir Weiterhelfen
Timbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 166



BeitragVerfasst: Do 25.05.06 15:01 
dann ist aber das ganze grid fett.
kann man das auch für eine bestimmte zelle hinbekommen?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Do 25.05.06 15:20 
klar, indem du aco, und arow auswertest und fsbold nur setzt, wenn es deien Zellen sind, sonst läßt du ihn leer
ausblenden Delphi-Quelltext
1:
Grid_Kal_Monat.Canvas.Font.Style + [];					


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Timbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 166



BeitragVerfasst: Do 25.05.06 15:46 
klar, danke, Du hast ja schon den canvas style genommen, dachte Du hättest den GridStyle benutzt...

funzt prima hier mal ein komplettes beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.MyGridDrawCell(Sender: TObject;
  ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
  //z.B. zeile 5 fett schreiben
  if ARow = 5 then begin
    //fett schreiben
    TStringGrid(Sender).Canvas.Font.Style:= [fsBold];
    //alte zelle überschreiben
    TStringGrid(Sender).Canvas.FillRect(Rect);
    // die schreibposition ein bißchen anpassen
    Rect.Top:= Rect.Top+2;
    Rect.Bottom:= Rect.Bottom+2;
    Rect.Right:= Rect.Right-1;
    Rect.Left:= Rect.Left+1; 
    //schreiben
    DrawText(TStringGrid(Sender).Canvas.Handle, PChar(TStringGrid(Sender).Cells[ACol,ARow]), StrLen(PChar(TStringGrid(Sender).Cells[ACol,ARow])), Rect,DT_LEFT);
  end;
end;