![]() |
StringGrid roter Rahmen
hallo,
möchte gerne einen roten rahmen im StringGrid haben, also die markierte Zeile soll einen rahmen haben.
Delphi-Quellcode:
if gdSelected in State then
StringGrid1.Canvas.Brush.Color := clMenu; StringGrid1.Canvas.FillRect( Rect ); StringGrid1.Canvas.TextRect( Rect, Rect.Left, Rect.Top, StringGrid1.Cells[ACol, ARow] ); Stringgrid1.Canvas.Pen.Color:=clRed; Stringgrid1.Canvas.Rectangle(Rect.Left, Rect.Top, Rect.Right StringGrid1.cells[aCol, aRow]); // was ist hier falsch? |
AW: StringGrid roter Rahmen
Fehlt da nicht ein begin\end?
gruss |
AW: StringGrid roter Rahmen
hey,
ist nur ein Ausschnitt! :-)
Delphi-Quellcode:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); begin StringGrid1.Canvas.Font.Color := clblack; if StringGrid1.Cells[0, ARow] = '1' then begin StringGrid1.Canvas.Brush.Color := $004080FF; end else if StringGrid1.Cells[0, ARow] = '2' then begin StringGrid1.Canvas.Brush.Color := $004080FF; end else if StringGrid1.Cells[0, ARow] = '3' then begin StringGrid1.Canvas.Brush.Color := $004080FF; end else if StringGrid1.Cells[0, ARow] = '11' then begin StringGrid1.Canvas.Brush.Color := $004080FF; end else if StringGrid1.Cells[0, ARow] = '4' then begin StringGrid1.Canvas.Brush.Color := clYellow; end else if StringGrid1.Cells[0, ARow] = '5' then begin StringGrid1.Canvas.Brush.Color := clyellow; end else if StringGrid1.Cells[0, ARow] = '6' then begin StringGrid1.Canvas.Brush.Color := clYellow; end else if StringGrid1.Cells[0, ARow] = '7' then begin StringGrid1.Canvas.Brush.Color := clYellow; end else if StringGrid1.Cells[0, ARow] = '8' then begin StringGrid1.Canvas.Brush.Color := clYellow; end else if StringGrid1.Cells[0, ARow] = '9' then begin StringGrid1.Canvas.Brush.Color := clYellow; end else if StringGrid1.Cells[0, ARow] = '10' then begin StringGrid1.Canvas.Brush.Color := clYellow; end; if gdSelected in State then StringGrid1.Canvas.Brush.Color := clMenu; StringGrid1.Canvas.FillRect( Rect ); StringGrid1.Canvas.TextRect( Rect, Rect.Left, Rect.Top, StringGrid1.Cells[ACol, ARow] ); Stringgrid1.Canvas.Pen.Color:=clRed; //Stringgrid1.Canvas.Rectangle(Rect.Left, Rect.Top, Rect.Right StringGrid1.cells[aCol, aRow]); // was ist hier falsch? end; |
AW: StringGrid roter Rahmen
Liste der Anhänge anzeigen (Anzahl: 1)
... ich glaube, der Markierungsrahmen wird in der Komplimentärfarbe zum Canvas.Brush gezeichnet :
versuch' mal Folgendes nach dem TextOut :
Delphi-Quellcode:
StringGrid1.Canvas.Brush.Color := clTeal;
if gdFocused in State then StringGrid1.Canvas.DrawFocusRect(Rect); |
AW: StringGrid roter Rahmen
Super ! Danke
|
AW: StringGrid roter Rahmen
Zitat:
Ich würde auch viel mehr Unterfunktionen verwenden. Damit bleibt der Quelltext z.B. für spätere Fehlersuche oder Änderungen lesbar.
Delphi-Quellcode:
function TForm1.GetColorForValue(AValue: Integer): TColor;
begin case AValue of 1..3, 11: Result := $004080FF; 4..10: Result := clYellow; else Result := clBlack; end; end; function TForm1.GetColorForCell(AState: TGridDrawState; AValue: Integer): TColor; begin if gdSelected in AState then Result := clMenu else Result := GetColorForValue(AValue, 0); end; procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin with StringGrid1 do begin {Hintergrund und Text, TextRect füllt auch den Hintergrund} Canvas.Brush.Color := GetColorForCell(State, IntToStrDef(Cells[0, ARow], 0)); Canvas.TextRect(Rect, Rect.Left, Rect.Top, Cells[ACol, ARow]); {Markierung} if gdFocused in State then begin Canvas.Brush.Color := clTeal; Canvas.DrawFocusRect(Rect); end; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:27 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