![]() |
StrinGrid Feldinhalt wird "Unsichtbar"
Hi also ich habe per folgendem Code meine Stringgridfelder weiß gemacht, und dann den Text mittig gesetzt.
Delphi-Quellcode:
Wenn ich nun ein Feld markiere und dann das Grid den Focus verliert "verschwindet" der Inhalt.
dy := (Rect.Bottom-Rect.Top-StringGrid1.Canvas.TextHeight(StringGrid1.Cells[ACol, ARow])) div 2;
dx := (Rect.Right-Rect.Left-StringGrid1.Canvas.TextWidth(StringGrid1.Cells[ACol, ARow])) div 2; if (acol = 0) or (arow = 0) then begin StringGrid1.Canvas.Brush.Color := clBtnFace; StringGrid1.Canvas.FillRect(Rect); StringGrid1.Canvas.TextOut(Rect.Left+dx, Rect.Top+dy, StringGrid1.Cells[ACol, ARow]); end; if (acol = 1) or (acol = 4) or (acol = 5) then begin if (arow >0) then begin StringGrid1.Canvas.Brush.Color := clWindow; StringGrid1.Canvas.FillRect(Rect); StringGrid1.Canvas.TextOut(Rect.Left+dx, Rect.Top+dy, StringGrid1.Cells[ACol, ARow]); end; end; Normalerweise wird das Feld ja blau und die Schrift weiß da ich die Felder aber im onDraw selbst bepinselt habe scheint nur die Schrift weiß (also unsichtbar) zu werden ... (nicht alle Felder sind weis hab auch rote/grüne aber da könnt ich damit leben) hat jemand ne Ahnung, wie ich das umgehen kann :gruebel: Wenn ich den Inhalt auch ohne das OnDraw-Bepinseln Zentrieren könnte könnte ich bei den weißen Feldern auch darauf verzichten und hätte dann das Problem nicht mehr :gruebel: aber wie ??? |
Re: StrinGrid Feldinhalt wird "Unsichtbar"
Hallo
du kannst entweder den State abfragen und auf gdselected prüfen, ob die Zelle selektiert ist. Statt clwindow dann clhighlight als Füllfarbe setzen . Wenn du keine Selektion anzeigen möchtest, dann setzt doch einfach die Schriftfarbe
Delphi-Quellcode:
da du die Schriftfarbe nicht setzt, ist sie clhighlighttext und diese ist je nach Einstellung u.U. weiß und du siehst nix.
canvas.font.color:=clwindowtext;
Mfg Frank |
Re: StrinGrid Feldinhalt wird "Unsichtbar"
Moin,
und das würde z.B. so aussehen...
Delphi-Quellcode:
MfG
with Sender as TStringGrid do begin
dy := (Rect.Bottom-Rect.Top-Canvas.TextHeight(Cells[ACol, ARow])) div 2; dx := (Rect.Right-Rect.Left-Canvas.TextWidth(Cells[ACol, ARow])) div 2; if (acol = 0) or (arow = 0) then begin Canvas.Brush.Color := clBtnFace; Canvas.FillRect(Rect); Canvas.TextOut(Rect.Left+dx, Rect.Top+dy, Cells[ACol, ARow]); end else begin if gdFocused in State then begin //Markierter Bereich end else if gdSelected in State then begin Canvas.Brush.Color := clHighlight; Canvas.Font.Color:=clWindow; end else begin Canvas.Brush.Color := clWindow; end; Canvas.FillRect(Rect); Canvas.TextOut(Rect.Left+dx, Rect.Top+dy, Cells[ACol, ARow]); end; end; Thorsten |
Re: StrinGrid Feldinhalt wird "Unsichtbar"
:wall:
Zitat:
Und falls mal was markiert werden muss kann ich ja immer noch die Abfrage einbauen. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:39 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 by Thomas Breitkreuz