Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Checkbox.Caption in Stringgrid (https://www.delphipraxis.net/88295-checkbox-caption-stringgrid.html)

Klaus01 13. Mär 2007 16:07

Re: Checkbox.Caption in Stringgrid
 
StringGrid1.Cells[1,StringGrid1.rowCount-1]:=(FindComponent( "CheckBox' + IntToStr( i)) as TCheckBox).caption;

Bei Dir/mir fehlte wohl eine Klammer.

Grüße
Klaus

Bruce86 13. Mär 2007 16:32

Re: Checkbox.Caption in Stringgrid
 
Liste der Anhänge anzeigen (Anzahl: 1)
also meckern tut er nicht mehr nur jetzt ist das problem anderswaltig da und zwar fängt er nicht in der 1.spalte an bzw in der ersten spalte zweite zeile sondern weiter unten aber eintragen tut er dafür schonmal vielen dank!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

vllt ne idee woran es liegen könnte?

problem siehe screenshot(s. scrollbar und freie felde über "deutsch")

Klaus01 13. Mär 2007 18:06

Re: Checkbox.Caption in Stringgrid
 
Ach so, Deine Tabelle hat schon eine bestimmte Anzahl an Zeilen.

Delphi-Quellcode:
Zeile :=1; // hier die Startzeile eintragen
for i := 1 to <Anzahl Checkboxen) do
begin
    if (FindComponent( "CheckBox' + IntToStr( i)) as TCheckBox).Checked then
      begin
        if Zeile >= StringGrid1.RowCount -1 then
          StringGrid1.RowCount:=StringGrid1.rowCount +1;
        StringGrid1.Cells[1,Zeile]:=(FindComponent( "CheckBox' + IntToStr( i)) as TCheckBox).caption;
        inc(Zeile);
      end;
end;
und zeile noch als Variable im Buttonklick vereinbaren.

Grüße
Klaus

Bruce86 13. Mär 2007 18:43

Re: Checkbox.Caption in Stringgrid
 
ok habe nun deinen rat befolgt! klappt wunderbar danke nur noch eine kleine frage wie schaffe ich es dann dass die erste zeile wenn ich nur eine habe fixed ist?

Klaus01 13. Mär 2007 18:50

Re: Checkbox.Caption in Stringgrid
 
Zitat:

Zitat von Bruce86
ok habe nun deinen rat befolgt! klappt wunderbar danke nur noch eine kleine frage wie schaffe ich es dann dass die erste zeile wenn ich nur eine habe fixed ist?

Wenn Du nur eine Zeile hast, hast Du keine fixed Zeile, das ist nun einmal so.
Dann mußt Du halt den Code zum befüllen des Grids entsprechend anpassen.
Zeile 0 ist dann die fixed Zeile
Zeile 1 ist leer, RowCount ist 2.
Delphi-Quellcode:
Zeile :=1; // hier die Startzeile eintragen
for i := 1 to <Anzahl Checkboxen) do
begin
    if (FindComponent( "CheckBox' + IntToStr( i)) as TCheckBox).Checked then
      begin
        if Zeile > StringGrid1.RowCount -1 then  // das = Zeichen aus >= entfernt
          StringGrid1.RowCount:=StringGrid1.rowCount +1;
        StringGrid1.Cells[1,Zeile]:=(FindComponent( "CheckBox' + IntToStr( i)) as TCheckBox).caption;
        inc(Zeile);
      end;
end;
Dann sollte das so gehen.

Grüße
Klaus

Bruce86 13. Mär 2007 19:00

Re: Checkbox.Caption in Stringgrid
 
Alles Bestens klappt einweindfrei! Vielen dank!


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:58 Uhr.
Seite 2 von 2     12   

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