AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TVirtualStringTree -> TStringGrid

Ein Thema von hoika · begonnen am 13. Feb 2009 · letzter Beitrag vom 13. Feb 2009
Antwort Antwort
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.270 Beiträge
 
Delphi 10.4 Sydney
 
#1

TVirtualStringTree -> TStringGrid

  Alt 13. Feb 2009, 19:14
Hallo,

ich will ein TVirtualStringTree in ein TStringGrid umformen.
Er ist wie ein ListView aufgebaut (ein RootNode, kein Baum).

Ich bin bisher soweit.


Delphi-Quellcode:
class procedure TListViewToolClass.LVToGrid(
  theListView: TVirtualStringTree; theStringGrid: TStringGrid);
var
  iCurCol : Integer;
  iCurRow : Integer;
  Node : PVirtualNode;
  sText : String;
begin
  theStringGrid.ColCount:= theListView.Header.Columns.Count;
  theStringGrid.RowCount:= theListView.RootNode.ChildCount+1;

  for iCurCol:= 0 to theListView.Header.Columns.Count-1 do
  begin
    theStringGrid.Cells[iCurCol, 0]:= theListView.Header.Columns[iCurCol].Text;

    for iCurRow:= 0 to theListView.RootNode.ChildCount-1 (?) do
    begin
      if Assigned(theListView.OnGetText) then
      begin
        Node:= theListView.RootNode. (?)
        theListView.FOnGetText(Self, Node, iCurCol, TextType, sText);
      end;
    end;
  end;
end; { TListViewToolClass.LVToGrid }

Bei der folgenden Zeile hänge ich.
for iCurRow:= 0 to theListView.RootNode.ChildCount-1 (?) do Wie bekomme ich die Zeilenzahl raus ?

Danke


Heiko
Heiko
  Mit Zitat antworten Zitat
Hawkeye219

Registriert seit: 18. Feb 2006
Ort: Stolberg
2.227 Beiträge
 
Delphi 2010 Professional
 
#2

Re: TVirtualStringTree -> TStringGrid

  Alt 13. Feb 2009, 19:39
Hallo Heiko,

ich würde so vorgehen:

Delphi-Quellcode:
var
  Col, Row : Integer;
  Node : PVirtualNode;
begin
  Grid.RowCount := VST.RootNodeCount + 1;
  Grid.ColCount := VST.Header.Columns.Count;

  for Col := 0 to Grid.ColCount - 1 do
    Grid.Cells[Col, 0] := VST.Header.Columns[Col].Text;

  Row := 1;
  Node := VST.GetFirst;
  while Assigned(Node) do
    begin
      for Col := 0 to Grid.ColCount -1 do
        Grid.Cells[Col, Row] := VST.Text[Node, Col];
      Inc (Row);
      Node := Node.NextSibling;
    end;
end;
Gruß Hawkeye
  Mit Zitat antworten Zitat
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.270 Beiträge
 
Delphi 10.4 Sydney
 
#3

Re: TVirtualStringTree -> TStringGrid

  Alt 13. Feb 2009, 20:01
Hallo,

habe gerade selber eine Lösung hinbekommen.

Trotzdem Danke


Heiko


Delphi-Quellcode:
class procedure TListViewToolClass.LVToGrid(
  theListView: TVirtualStringTree; theStringGrid: TStringGrid);
var
  iCurCol : Integer;
  iCurRow : Integer;
  Node : PVirtualNode;
  sText : UnicodeString;
begin
  theStringGrid.ColCount:= theListView.Header.Columns.Count;
  theStringGrid.RowCount:= theListView.RootNode.ChildCount+1;

  for iCurCol:= 0 to theListView.Header.Columns.Count-1 do
  begin
    theStringGrid.Cells[iCurCol, 0]:= theListView.Header.Columns[iCurCol].Text;

    Node:= NIL;

    for iCurRow:= 0 to theListView.RootNodeCount-1 do
    begin
      if iCurRow=0 then
      begin
        Node:= theListView.RootNode.FirstChild;
      end
      else
      begin
        Node:= Node.NextSibling;
      end;

      if Assigned(theListView.OnGetText) then
      begin
        theListView.OnGetText(theListView, Node, iCurCol, ttNormal, sText);

        theStringGrid.Cells[iCurCol, iCurRow+1]:= sText;
      end;
    end;
  end;
end; { TListViewToolClass.LVToGrid }
Heiko
  Mit Zitat antworten Zitat
Antwort Antwort


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 07:27 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