Google @ Translated to: English(¥] | Show original Options v | [x]
® @ Vv aG
Tas
El Delphi-PRAXIS => programming general > GUI design with VCL FireMorkey / Common Controls
‘Deiphi VirtualTreeView and tree structure > |
VirtualTreeView and tree structure Theme options\7 view‘ _ Search topic 7
‘Atopic by Alb started on Mar 22, 2004 «last post on Mar 25, 2004
[B answer
VirtualTreeView and tree structure
Albi EEiMar 22, 2004 9:17 pm
Registered on: May 4tn, 2003 Good evening,
Location: Beslin
458 Posts got the compo from Delphi Gems and am now faced with the
blph 7 professional Problem that I can not get @ SubNode added.
‘That means, I know how to do this via Btn but I get the data from a
‘query, and put it into a record. Now there are other data in the query,
‘hich I would lke to enter in the SubNode. So that it looks something
lke this.
With this code I write the data in the ListView.
Delphi source code: fold up * mark
CustRec: = Sender.GetNodedata (Node);
Initialize (custRec *);
CustRec.AVornane: = Queryi.Fields [@] .AsString;
CustRec.ANane: = Queryi.Fields [1] .AsString;
CustRec.AVornaneGF1: = Queryi.Fields [2] .AsStrings
CustRec.ANaneGF1: = Queryi.Fields [3] .AsString:
if not Query1.EoF Then
Queryt.Next
end 5
procedure TFornl.VsTGetText (Sender: TBaseVirtualTree; Node:
PvintualNode;
Colunn: TColunnIndex; TextType: TVSTTextType; var
Celltext: Widestring);
var CustRec: PCustRec;Sender.GetNodeData (Node);
@ Then
Albi
Registered on: May 4th, 2003,
Location: Berlin
458 Posts
Delphi 7 Professional
DelphiDeveloper
Registered on: Apr 9, 2003
Location: Cologne
256 posts
Delphi XE2 Enterprise
TustRec.AVorname;
1 Then
CustRec.ANane;
TF Colunn
celltext:
ends
Re: VirtualTreeView and tree structure
242004 12.23,
Cave]
Don't any of you know any advice? Or any other compo that makes it
possible for me?
GC) jG)
Re: VirtualTreeView and tree structure
Mar 24, 2004 2:04 pm
T wrote a few snippets of code here how I managed it.
1) Definition of the data I need
Delphi source code: fold up ~ mark
‘TireebataClass = class
private
Fleststri: strings
FOoKTD: integer
FKDID: integers
FICON: integer;
FOOKNR: strings
FMASUCH: strings
FookDatun: Toate;
FUserinitial: strin
FMandant: integers
Fookart: TookTypen;
FOokKuerzel: strings
published
Property Teststri: string read Freststri write
Freststra;
Property DokID: integer read FDOKIO write FOokID;
property KOID: integer read FKDID write FKDID;
Property ICON: integer read FICON write FICON;
Property DokDatun: TDate read FDokOatum write FDokDatun;
property Userinitial: string read FUserinitial write
FuserInitial;
property Mandant: integer read FMandant write Flandant;
Property DOKNR: string read FDOKNR write FDOKNR;
Property MASUCH: string read FMASUCH write FMASUCH;
Property DokArt: TbokTypen read FOOKArt write FDokArt;
Property DokKuerzel: string read FOokKuerzel write
FookKuerzel;
fend; //class
PTreedata = “TTreepata;
Trreebata = record
Fooject: Tobject;
end;
2, Method for adding nodesDelphi source code: to mark
| function TForaChildarchiv.AddvSTObject (avst:
TcustonVirtualstringTree;
aNode: PVirtualNode; adbject: Tobject}
var
Data: PIreedata;
begin
Result := avst.AddChild(aNode) ;
avst.ValidateNode(Result, False);
data := avst.GetNodebata(Result);
data*.Fobject := adbject;
end;
PvirtualNode;
3, Filling the data structures with values from the Qi
Delphi source code: fold up * mark
procedure TFornchildarchiv.BuildTree;
Treeobject: TTreedataClass;
Root: PVirtualNode;
begin
vst.Beginupdate;
vst.NodebataSize: = sizeof (TTreebata}
vst.Deletechildren (vst.RootNode, true);
4if marked (OFFER) then
begin
U/ enter root
‘Treeobject: = TrreebataClass.Create;
try
Treedbject.DokArt: = OFFER;
Treedbject DokKuerzel: = "ANG";
Treedbject.TestStri: = GetOKBEZ (GetEnunNane (TypeInfo
(TDoktypes),
ord (Treedbject.Dokart))) +
"(4 IntToste (1B_QryAngebote.Recondcount) + ')";
if 1B _QryAngebote.Recordcount > @ then
TreeObject.Tcon := 3
else
Treeobject.teon := 12}
Wurzel i= addvstobject(vst, nil, Treedbject);
// jetzt Detail eintragen
with 18_QryAngebote do
begin
While not Eof do
begin
Treeobject
try
Treeobject.Teststra
Fi.e]dByName('KU_SUCH")-AsStrings
TreeObject-DokID +
FieldByName('AK_1D") .AsIategers
TreeObject .KDID i= FieldByName(*AK_KU_ID *)
-asintegers
Treeobject.DokDatum: = FieldByNane (" AK_DATE ')
TrreebataClass.Create;
casdate;
Treeobject.Userinitial: = FieldByNane (*
USER_INITIAL *) .asStrings
TreeObject.Mandant: = FleléByNane (" AK_MANDANT
") sastntegers
‘TreeObject.DOKNR: = FieldByName (* AK_NR *)
-asstrings
I // Teedbject. Icon: = 17;
L adductOhiart fuch Anant Taaadhtart\except
Treedbject.free
TT ea 7
Next
end j // while
end
except
Treedbject.free
end 5 // try
TB_QryAngebote.Close;
end ; // if enter offers
if marked (REQUEST) then
begin
U/ enter root
‘Treeobject: = TtreebataClass.Create;
try
Treedbject.dokart
Treedbject .DokKuerzel
Treedbject.TestStri: =
GetDkBEZ (GetEnumane (TypeInfo (TDokTypes)
ford (Treedbject.Dokart))) +
"(' # IntTostr (IB_QryAnfragen.Recondcount) +‘ )
REQUESTS
= AME 5
if IB_QryAnfragen.Recordcount> @ then
‘Treeobject.Icon! = 2
else
TreeObject.Icon: = 125
Root: = addvstobject (vst, nil , Treedbject);
// enter this detail
with TB_gryActivate do
begin
While not Eof do
= TrreepataClass. Create;
Treeobject. Teststr
FieldByName (" KU_SUCH *)
-Asstrings
TreeObject.DokID: = FieldbyNane (* ANID *)
-astnteger;
TreeObject.KDID: = FieldByNane (‘ KU_ID ')
-AsIntegers
TreeObject .Dokbatun: = FieldByNane (*
AN_SERVERDATE ") .asdate;
TreeObject.Userinitial i=
Fi.eLdByName('USER_INITIAL") .asStrings
Treedbject .Mandant :=
Fi.eLdByName('MANDANT_Ib") AsInteger
‘Treeobject .DOKNR
FileldByNane("AN_NR").asstring
Vi Teeedbject.Leon += 173
addvstobject(vst, Wurzel, Treedbject);
except,
Treedbject. free;
ends //try
Next
fend; // wile
end; // with
except
Treeobject.Free
ends //try
18_QryAnfragen.Close;
ends // if,
Under 3 there is still a lot of balast, The decisive factor for the tree
structure
is addvstObject
(Gal[S/@s)
Quote || # Report |Re: VirtualTreeView and tree structure
Mer 24, 2004 8:38 pm
sejsteres on: Hay st, 2009 THANK you for the code, T have already tried it but now I Yace the next
Location: Bertin problem. What else has to be done that he shows me the data in the
458 Posts VST. The way I've tried it so far is no longer possible.
Albi
Delphi 7 Professional
So far I've done that with CellText: = .. but it doesn't work here.
‘Slowly I no longer believe that this compo is as simple as I read it.
| S/e)
Re: VirtualTreeView and tree structure
Mar 24, 2004 9:34 prm
quote P Repo)
DelphiDeveloper
registered on: Apr9, 2003 The following events are interesting for the beginning,
Location: Cologne The code belongs to the source code from above. I hope you can
256 posts handle it:
Delphi XE2 Enterprise
1, Show text
Delphi source code: fold up * mark
procedure TFonnchildarchiv.vstGetText (Sender:
TeaseVirtual Tree;
Node: PVirtualNode; Column: Integer; TextType:
TsTTextType;
var Celltext: Widestring);
var
bata: Prreebata;
begin
Data := Sender.GetNodeData(Node) ;
if data.FObject <> nil then
begin
case Column of
@:
begin
if Node.Parent = Sender.RootNode then
celltext
TrreebataClass (Data. FObject).FTeststri
else
celltext
TrreebataClass (Data.FObject).FTeststri
fend;
a:
Uf Node.Parent = Sender.RootNode then
celltext i="
else
celltext i=
DateTostr(TTreebataClass (Data. FObject).FDokDatun) ;
2:
f Node.Parent = Sender.RootNode then
celltext ="
else
celltext := TTreebataClass (bata. Fobject) .MASUCHs
Uf Node.Parent = Sender.RootNode then
celltext i="
else
celltext
TrreebataClass (Oata. Fobject).FUsertnitial;
4
Uf Node.Parent = Sender.RootNode then
celltext i="
Liease
celltext := TrreedataClass(Data.Fobject) .FOOKNR;
Tena
end;
end;
2, Show pictures
Delphi source code: fold up * mark
procedure TrornChildarchiv.vstGetInageIndex(Sender:
TeaseVirtual Tree;
Node: PVirtualNode; Kind: TVTImagekind; Column: Integer;
var Ghosted: Boolean; var InageIndex: Integer);
var
ata: PTreeData;
begin
Data := Sender.GetNodeData(Node) ;
case Kind of
ikNiornal, ikSelectes
Af (Colurn = @) and (Node.Parent = Sender.RootNode)
‘then
Inagelndex := TrreedataClass (Data. Fobject).Lcon;
akstate:
‘case Column of
Af Node.Parent <> Sender.RootNode then
Inagelndex
3, sort the columns
Delphi source code: fold up» mark
procedure Trornchildarchiv.vstHeaderClick(Sender: TVTHeader;
Colunn: Integer; Button: TMouseButton; Shift: Tshiftstate;
x,
Ys Integer);
begin
if Buttor
begin
with Sender, Treeview do
begin
Uf Sortcolunn > Nocolumn then
Columns[SortColunn] .options
Colunns[Sortcolunn] options + [coParentcolor];
mbLeft then
// bo not sort the Last column, it contains nothing to
sort.
if Column = @ then
SortColunn := NoColumn
else
begin
iF (SortColunn = NoColunn) or (SortColumn <> Colunn)
then
begin
‘Sortcolunn: Colunn
SortDirection: = sdascending;
end
else
Af SortDirection = sdtscending then
SortDirection: = sddescending
else
SortDirection: = sdascending;
Columns [SortColunn] .Color: = $ FIF7F75
Li Sort Tres. (SantCalunn. SantDinection.Falce):end
end 5
Albi
Registered on: May 4th, 2003,
Location: Beslin
458 Posts
Delphi 7 Professional
Ted
end
procedure TFornChildarchiv.vstConpareNodes. (Transmitter:
TeaseVirtualTree; Node,
Node2: PVirtualNode; Column: Integer; var Result:
Integer);
Datei, Data: PTreebata;
Sender.GetNodeData(Node1) ;
Sender. GetNodeData(Node2) ;
case Column of
e
Result :=
ConpareText (TtreeDataClass (Datal.FObect) .Teststr1,
TtreedataClass (Data2.FObject).TestStr1);
a
Result := Trunc(TTreebataClass(Data1.FObject).DokDatun
TrreebataClass (Data2.FObject).DokDatum) ;
2
Result :=
ConpareText (TTreebataClass(Datai .FObject) .MASUCH,
‘TrreedataClass (Data2.FObject) .MASUCH) ;
3:
Result 2
ConpareText (TTreeDataClass (Datal.FObject) UserTnitial,
‘TireeataClass(Data2.FObject) .Userinitial) ;
a:
Result
StrToInt(TTreeDataClass(Datat.FObject).DOKNR) -
StrToInt(TTreebataClass (Data2.FObject) .DOKNR) ;
4, Release the nodes
Delphi source code: to mark
procedure TFornChildarchiv.vstFreeNode(Sender:
TeaseVirtual tree;
Node: PVirtualNode) ;
Data: PTreeData;
begin
Data := VST.GetNodedata(Node) ;
if not Assigned(Data) then
exit;
Data. FObject.Free;
end;
Hope you can handle it
Sa) Save ere)
Re: VirtualTreeView and tree structure
(Mar 25, 2004 7:23 am
‘Thank you for the help, I have modified your code a little and now
have a week and a lot of help from you the desired result,
Here is the code for everyone who has the same problem.Delphi source code:
f
fold up * mark
[Procedure TForwl.@ulldtres;
var
Treedbject: TrreebataClass;
Root: PVirtualNode;
begin
VsT.BegirUpdate;
VST.Nodebatasize: = sizer (TTreeData);
vsT.peletechildren (VST.RootNode, true);
nile Not Query1.foF Do
Begin
Treedbject: = TreebataClass.create;
‘TreeObject.Vornane: = Query1.FieldiyNane (‘ MVornane
sAssteings // The root
TreeObjject are entered here. Name : = Query1.fieldByNane
(tMiane *) .Asstring;
Root: = AddvsTObject (VST, Nil , Treedbject);
IF Query1.FieldByNane("PNaneGF1").AsString > '* Then //
the notes are read here
Begin
Treeobject: = TreedataClass.creates
ty
TF Query1.FieldByNane (* MNanesFa *) .AsString>
"Then
Query1. FieldByiane("NameGF1') AsStrings
Treedb ject .VornaneGFt i
‘Query. FieldByiame("VornaneGra") AsStrings
Addvstobject (VST, wurzel, Treedbject);
end;
except
Treedbject.Free;
end;
‘end;
Query Next;
ends
vst. Endupdate;
end;
left the rest as above and I can only say many thanks.
Re: VirtualTreeView and tree structure
Mar 25, 2004 11:19 am
Albi
calstored on: May 4tn, 2003 $0 NOW T have everything and it runs without problems. I still have
Location: Bertin ‘one question. What do I have to set that I can also sort by the first
458 Posts column, I have already looked through the example and compared the
settings but found nothing I definitely just missed something but I
just don't find it,
eovere | ¥ never]
[GaGa
Re: VirtualTreeView and tree structure
EMer 25, 2004 11:57
Delphi 7 Professional
DelphiDeveloper
Registered on: Apr 9, 2003
Location: Cologne Delphi source code: fold up“ mark
256 posts
procedure TFornChildArchiv.vstHeaderClick(Sender: TVTHeader;
Delphi xE2 Enterprise Colunn: Integer; Button: TMouseButton; Shift: TShiftstate;
x
“ys Integer);
begin
Oe oueton = nbLeft thenbegin
ith Sender, Treeview do
begin
— SortColuen > WeCoTuen then
Columns[SortColumn] .Options
coluans[Sortcoiuan] options + [coParentColor];
4f (SortColumn = NoColunn) or (SortColumn <> Column)
begin
SortColumn := Column;
SortDirection := sdAscending;
end
else
Af SortDirection = sdascending then
SortDirection := sddescending
else
SortDirection := sdascending;
Columns {SortColunn] .Color := $F7F7F73
SortTree(SortColumn, SortDirection, False);
end; :
ends
it is not if you shit my special treatment of the Oth column.
did it with me on the fast and it works.
Qik)
Re: VirtualTreeView and tree structure
‘Mar 25, 2004 1:16 pm
Albi
Resistered on: May 4th, 2003 1 alSo Saw it, Until then, however, was of the opinion that it was due
Location: Bertin to the VST attitude. Until I looked at the source text of the examples
458 Pests and then the enlightenment came.
Delphi 7 Professional
‘So now I have everything and it looks much nicer and more sorted
‘than just in a ListView,
(GaJSa a) Pavere |
Re: VirtualTreeView and tree structure
EElMer 25, 2004 1:58 pm
DelphiDeveloper
Resstered on Ape9, 2003 YeS, the Virtual TreeView is a powerful component. At first
Location: Cologne glance it is a little difficult to act, but once you understand it,
256 posts you can get by.
Delphi XE2 Enterprise
‘Thanks to Mike Lischke!
Virtual tree view
‘« Previous topic | Next topic »
Edit keywordsForum rules
You ate allowed to write new topics.
You are allowed to reply to posts.
You are allowed to upload attachments.
‘You are allowed to edt your posts.
BB code is on
Smiles are on
[IMG] code is on
HTML code is out
“Trackbacks are an
Pingbacks are an
Refbacks are off
Forum rules Goto:
{GUEDesign mit VOL JFireMonkey ‘Common Conttls | The
Se es cease cae