AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Farbe von mit OnDrawcell gefärbter StringGridZelle abfragen
Thema durchsuchen
Ansicht
Themen-Optionen

Farbe von mit OnDrawcell gefärbter StringGridZelle abfragen

Ein Thema von Stecky2000 · begonnen am 5. Nov 2008 · letzter Beitrag vom 7. Nov 2008
 
Stecky2000

Registriert seit: 7. Mai 2008
Ort: Trebur
66 Beiträge
 
Delphi 2010 Professional
 
#6

Re: Farbe von mit OnDrawcell gefärbter StringGridZelle abfra

  Alt 5. Nov 2008, 14:50
Hallo TaakTaak,

Danke für die Antwort, aber ich verstehe es nicht.

In meinen OnDrawCell wird wie folgt vorgegeangen:

Delphi-Quellcode:

procedure TDPLForm.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);

begin
  with (Sender as TStringGrid) do
  begin
    // Don't change color for first Column, first row
    if (ACol = 0) or (ARow = 0) then
      Canvas.Brush.Color := clBtnFace
    else
    begin
         if (cells[ACol, ARow] <> '') and (cells[ACol, ARow] <> ' ') then
           if cells[ACol, ARow] = StringGrid3.Cells[0, StrToInt(cells[ACol, ARow])] then
               begin
                    if (StringGrid3.Cells[1, StrToInt(cells[ACol, ARow])] = 'x') or (StringGrid3.Cells[1, StrToInt(cells[ACol, ARow])] = 'X') then
                       begin
                            Canvas.Brush.Color := clLime;
                            Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
                            Canvas.FrameRect(Rect);
                       end;
                    if (StringGrid3.Cells[1, StrToInt(cells[ACol, ARow])] = 'd') or (StringGrid3.Cells[1, StrToInt(cells[ACol, ARow])] = 'D') then
                       begin
                            Canvas.Brush.Color := clRed;
                            Canvas.Font.Color := clWhite;
                            Canvas.Font.Style := [fsbold];
                            Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
                            Canvas.FrameRect(Rect);
                       end;
                    if (StringGrid3.Cells[1, StrToInt(cells[ACol, ARow])] = 'g') or (StringGrid3.Cells[1, StrToInt(cells[ACol, ARow])] = 'G') then
                       begin
                            Canvas.Brush.Color := clBlue;
                            Canvas.Font.Color := clWhite;
                            Canvas.Font.Style := [fsbold];
                            Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
                            Canvas.FrameRect(Rect);
                       end;
                    if (StringGrid3.Cells[2, StrToInt(cells[ACol, ARow])] = '') then
                       begin
                            Canvas.Brush.Color := clBlack;
                            Canvas.Font.Color := clWhite;
                            Canvas.Font.Style := [fsbold];
                            Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
                            Canvas.FrameRect(Rect);
                       end;
               end;
    end;
  end;
end;

Ich schreibe die Farbe also nur mit

Canvas.Brush.Color := clLime; rein.

Ich habe darauf hin und nach deiner Antwort folgendes versucht, aber ohne Erfolg:

Color := Integer(StringGrid1.Objects[j, i]); Das geht aber auch nicht, da steht in der Variablen Color immer nur 0 drin;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:37 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