was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

37 Visitors Online


 
...den Inhalt eines TStringgrids/ TDrawGrids als String erhalten?
Autor: Thomas Mueller
Homepage: http://www.s2h.cx
[ Tip ausdrucken ]  

Tip Bewertung (4):  
     


{
 This copies the contents of a TstringGrid/TDrawGrid (only Text!!) into a string.
 Tabs are inserted between the columns, CR+LF between rows.
}

use
  Grids;

{...}

{ we need this Cracker Class because the Col/RowCount property
  is not public in TCustomGrid }
type
  
TGridHack = class(TCustomGrid);

function GetstringGridText(_Grid: TCustomGrid): string;
var
  
Grid: TGridHack;
  Row, Col: Integer;
  s: string;
begin
  
// Cast the paramter to a TGridHack, so we can access protected properties
  
Grid   := TGridHack(_Grid);
  Result := '';
  // for all rows, then for all columns
  
for Row := 0 to Grid.RowCount - 1 do
  begin
    for 
Col := 0 to Grid.ColCount - 1 do
    begin
      
// the first column does not need the tab
      
if Col > 0 then
        
Result := Result + #9;
      Result := Result + Grid.GetEditText(Col, Row);
    end;
    Result := Result + #13#10;
  end;
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners