Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Tstringgrid auffüllen (https://www.delphipraxis.net/69058-tstringgrid-auffuellen.html)

philiph 9. Mai 2006 17:20


Tstringgrid auffüllen
 
Hallo,
wie kann ich alle noch leeren Felder in einem Stringgrid mit einem zufällig generierten Buchstaben auffüllen?

marabu 9. Mai 2006 17:44

Re: Tstringgrid auffüllen
 
Zum Beispiel so:

Delphi-Quellcode:
procedure RandomFillGrid(sg: TStringGrid);
var
  iCol, iRow: Integer;
begin
  with sg do
    for iRow := FixedRows to Pred(RowCount) do
      for iCol := FixedCols to Pred(ColCount) do
        if Cells[iCol, iRow] = '' then
          Cells[iCol, iRow] := Chr(Ord('A') + Random(26));
end;
Grüße vom marabu

Klaus01 9. Mai 2006 18:33

Re: Tstringgrid auffüllen
 
.. und im Form1.create das randomize nicht vergessen

Grüße
Klaus


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:51 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