LMuadDIb
asked on
using the virtual treeview...
Im new to using the component Virtual TreeView
and to be honest I cant figure it out
I have a project where I have my own record arrays and I want to be able to use the array in the virtual treeview but I am a lost.
There is an example that comes with it that is suppose to show me I think, but I cant seem to figure it out with my arrays.
Basically Im trying to create my own bookmark form for an application, and I want to use the virtual tv to display the bookmarks,
I store each property of the bookmark in an array record... the tv will only display a couple items from the record though and not all.
I have read the help files and gone through the demos for the compenent...
Anyways, can someone here show me the basics of using the virtual treeview with your own record arrays?
My project
and to be honest I cant figure it out
I have a project where I have my own record arrays and I want to be able to use the array in the virtual treeview but I am a lost.
There is an example that comes with it that is suppose to show me I think, but I cant seem to figure it out with my arrays.
Basically Im trying to create my own bookmark form for an application, and I want to use the virtual tv to display the bookmarks,
I store each property of the bookmark in an array record... the tv will only display a couple items from the record though and not all.
I have read the help files and gone through the demos for the compenent...
Anyways, can someone here show me the basics of using the virtual treeview with your own record arrays?
My project
I used TTreeView in an HTML parser, here: https://www.experts-exchange.com/questions/20830833/Extract-links-from-a-website.html
set the VTV's NodeDataSize to SizeOf(YourRecord);
adding the items the proper way: set RootNodeCount, in the OnInitNode event set the node's data, handle OnInitChildren ...
the not recommended way: VTV.AddNode(ParentNode, nodedata); (I use this as it's more readable :D)
you could do:
VTV.AddNode(nil, @TheArray[Index]);
in OnGetCellText
case ColumnIndex of
0: CellText:=PMyRec(Sender.Ge tNodeData( Node)).Val ueAsString ;
end;
PMyRec = ^TMyRec; ... this I hope you know what it is :)
adding the items the proper way: set RootNodeCount, in the OnInitNode event set the node's data, handle OnInitChildren ...
the not recommended way: VTV.AddNode(ParentNode, nodedata); (I use this as it's more readable :D)
you could do:
VTV.AddNode(nil, @TheArray[Index]);
in OnGetCellText
case ColumnIndex of
0: CellText:=PMyRec(Sender.Ge
end;
PMyRec = ^TMyRec; ... this I hope you know what it is :)
ASKER
sftweng, Virtual Treeview is quite different from the standard TTreeview
Lee_Nover, can you elaborate more? esp about the pointer?
here is my record array and code:
type
TMyRecord = record
Name : string[255];
Nick : string[255];
Address : widestring;
Description : widestring;
Created : string[50];
Visited : string[50];
ParentFolder : widestring;
end;
var
RecArrData: array[0..10] of TMyRecord;
procedure TForm1.LoadArrayIntoTV();
var
i : integer;
begin
{we add random info into the array then }
{ set the VTV's NodeDataSize to SizeOf(YourRecord); }
VT.NodeDataSize := SizeOf(RecArrData);
for i := 0 to 10 do
VT.AddChild(nil, @RecArrData[i].Name);
end;
procedure TForm1.VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
//var
//Data: ^rTreeData;
begin
case Column of
0: CellText:=PVirtualNode(Sen der.GetNod eData(Node )).ValueAs String;
end;
end;
when you stated "PMyRec = ^TMyRec;"
my record array should look like so instead of the above def, adding a pointer to the record:
type
PVirtualNode = ^TMyRecord;
TMyRecord = record { RECORD FOR BOOKMARKS DUH! }
Name : string[255];
Nick : string[255];
Address : widestring;
Description : widestring;
Created : string[50];
Visited : string[50];
ParentFolder : widestring;
NodePointer : PVirtualNode;
end;
but I get incompatable types ... hmmm
sorry for the late reply, just been working alot
thanx
Lee_Nover, can you elaborate more? esp about the pointer?
here is my record array and code:
type
TMyRecord = record
Name : string[255];
Nick : string[255];
Address : widestring;
Description : widestring;
Created : string[50];
Visited : string[50];
ParentFolder : widestring;
end;
var
RecArrData: array[0..10] of TMyRecord;
procedure TForm1.LoadArrayIntoTV();
var
i : integer;
begin
{we add random info into the array then }
{ set the VTV's NodeDataSize to SizeOf(YourRecord); }
VT.NodeDataSize := SizeOf(RecArrData);
for i := 0 to 10 do
VT.AddChild(nil, @RecArrData[i].Name);
end;
procedure TForm1.VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
//var
//Data: ^rTreeData;
begin
case Column of
0: CellText:=PVirtualNode(Sen
end;
end;
when you stated "PMyRec = ^TMyRec;"
my record array should look like so instead of the above def, adding a pointer to the record:
type
PVirtualNode = ^TMyRecord;
TMyRecord = record { RECORD FOR BOOKMARKS DUH! }
Name : string[255];
Nick : string[255];
Address : widestring;
Description : widestring;
Created : string[50];
Visited : string[50];
ParentFolder : widestring;
NodePointer : PVirtualNode;
end;
but I get incompatable types ... hmmm
sorry for the late reply, just been working alot
thanx
LMuadDIb, thanks for the clairification. I'm not familiar with it; we're using the DevExpress components.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanx alot Lee_Nover :)
got it working with your help, I appreciate it =)
got it working with your help, I appreciate it =)