Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Stringgrid DrawCell (https://www.delphipraxis.net/54516-stringgrid-drawcell.html)

hansklok 5. Okt 2005 19:16


Stringgrid DrawCell
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,

ich schreibe gerade für ein Unternehmen eine Software, die eine Umfrage durchführt. Gefragt wird u.a., ob man das Unternehmen kennt. Alle Datensätze werden in einem Stringgrid ausgegeben. Nun sollen die Zeilen (Datensätze) rot markiert werden, die auf die Frage, ob sie das Unternehmen kennen mit nein geantwortet haben. einen Such-Algorithmus habe ich schon, aber wie realisiere ich die rote Hinterlegung der zeilen?

MfG

hansklok

Hansa 5. Okt 2005 19:27

Re: Stringgrid DrawCell
 
ungefähr so :

Delphi-Quellcode:
procedure Tfrm.sgDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  inherited;
  if (ARow >= sgNr.FixedRows) and (ACol >= sgNr.FixedCols) then begin
    if sgNr.Cells [NeinSpalte,ARow] = 'N' then with Sender as TStringGrid do begin
      sgNr.Font.Color := clwhite;
      sgNr.Brush.Color := clRed;
    end
  end
end;

hansklok 5. Okt 2005 19:30

Re: Stringgrid DrawCell
 
@ hansa: Was bedeutet dies:
Delphi-Quellcode:
sgRechts(sgArtNr, Rect, ACol, ARow);
Ist das ein Aufruf für ein TRect?

Bei mir heißt das Stringgrid tTabelle und bei der Spalte handelt es sich um die 3.

Das habe ich von deinem Code bisher so eingegeben:

Zitat:

inherited;
if (ARow >= tTabelle.FixedRows) and (ACol >= tTabelle.FixedCols) then begin
if tTabelle.Cells [3,ARow] = 'N' then with Sender as TStringGrid do begin
Rectangle(tTabelle.Canvas.Handle, 0,0,i,3); ---> Diese Zeile ist mir unklar
//sgRechts(sgArtNr, Rect, ACol, ARow);
end
mfg

hansklok

hansklok 5. Okt 2005 19:41

Re: Stringgrid DrawCell
 
Ich habe es selbst hinbekommen. Es hätte so aussehen müssen:

Delphi-Quellcode:
var
 i: Integer;
...
with tTabelle do
  begin
      for i:= 1 to tTabelle.RowCount-1 do
        begin
          if tTabelle.Cells[3, ARow] = 'Nein' then
          begin
         Canvas.Font.Color := clRed;
         Canvas.Brush.Style:= bsSolid;
         Canvas.TextRect(Rect, Rect.Left + 2,
                         Rect.Top + 2, Cells[ACol, ARow]);
         end
      end;
   end;

Hansa 5. Okt 2005 20:25

Re: Stringgrid DrawCell
 
Das sgRechts war ein Fehler. Bei mir ist das gleich rechtsbündig usw. Habe es editiert. Aber der Code mit dem for i :=... der steht doch hoffentlich nicht in dem OnDrawCell ? :shock:


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:40 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz