![]() |
DB Grid - 1. Spalte einfärben
Hallo!
Gibt es wie im Datagrid irgendwie die Möglichkeit, die jeweils 1. Spalte wie die Titelzeile einzufärben? |
Re: DB Grid - 1. Spalte einfärben
Meinst du Sowas wie
Delphi-Quellcode:
Oder die 1. Spalte in eine bestimmte Farbe färben
StringGrid.FixedCols
Delphi-Quellcode:
Ups, seh gerade es ging um DB-Grid und nicht StringGrid :wall: :oops:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); begin with (sender as tStringGrid) do if ACol = 0 then begin Canvas.Brush.Color := clRed; Canvas.FillRect(Rect); Canvas.TextOut(Rect.Left+2, Rect.Top+2, (sender as tstringgrid).Cells[ACol, ARow]); end; end; |
Re: DB Grid - 1. Spalte einfärben
Genau sowas!
Nur für's DB Grid. ;) /edit: hehe, jep. :) |
Re: DB Grid - 1. Spalte einfärben
Hab jetzt folgenden Code gefunden und modifiziert:
Delphi-Quellcode:
Nun möchte ich, dass in dieser Spalte auch fett geschrieben wird:
procedure TVertretungen.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if Column.FieldName = 'KLASSEN' then begin DBGrid1.Canvas.Brush.Color := clGradientActiveCaption; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end; end;
Delphi-Quellcode:
Das eingefügt bewirkt leider so überhaupt nichts. :(
DBGrid1.Canvas.Font.Style := [fsBold];
/edit:
Delphi-Quellcode:
Mit dem Code funktionierts!
procedure TVertretungen.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if Column.FieldName = 'KLASSEN' then begin DBGrid1.Canvas.Brush.Color := clGradientActiveCaption; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); DBGrid1.Canvas.Font.Style := [fsBold]; DBGrid1.Canvas.TextRect(Rect,Rect.Left, Rect.Top,Column.Field.AsString); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:33 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz