Hi,
I would need to allow a user selecting an objects from a hierarchy (for filtering a report).
Therefore I was about to use a TreeViewControl on a form. Unfortunately I don't really know how to populate the tree inside the control (based on hierarchical data retrieved from a datasource) and how to get the selected value afterwards.
Could you pls give some advice?
BR, Andreas
how to populate a treeviewcontrol?
Re: how to populate a treeviewcontrol?
Hello.
We use standard .Net Framework component - TreeView Class.
You could use next code:
Thank you.
We use standard .Net Framework component - TreeView Class.
You could use next code:
Code: Select all
treeView1.Control.Nodes.Add("Parent");
treeView1.Control.Nodes[0].Nodes.Add("Child 1");
treeView1.Control.Nodes[0].Nodes.Add("Child 2");
treeView1.Control.Nodes[0].Nodes[1].Nodes.Add("Grandchild");
treeView1.Control.Nodes[0].Nodes[1].Nodes[0].Nodes.Add("Great Grandchild");
Re: how to populate a treeviewcontrol?
Hi Aleksey,
thx for your answer. Very much appreciated. Got it to work with hard coded values.
Next step would be to populate the tree using (filtered) hierarchical data from a datasource (in fact from two related datasources in my case). I feel I would be able to use proper databands to fetch the records needed to populate the tree but then I would a way to show the form to the user AFTER I have processed some databands.
As far as I understood from the property "Start Mode" available for forms there seems to be no way to display the form in the middle of the report generation.
Alternatively I could use the "Load Form" event of the form to populate the tree (as I did for the hard-coded values) but then I would need a way to fetch the data (including its hierarchy) from the datasources within the code of the event.
Can you pls also give some hints here how this can be achieved?
Many thanks in advance,
Andreas
thx for your answer. Very much appreciated. Got it to work with hard coded values.
Next step would be to populate the tree using (filtered) hierarchical data from a datasource (in fact from two related datasources in my case). I feel I would be able to use proper databands to fetch the records needed to populate the tree but then I would a way to show the form to the user AFTER I have processed some databands.
As far as I understood from the property "Start Mode" available for forms there seems to be no way to display the form in the middle of the report generation.
Alternatively I could use the "Load Form" event of the form to populate the tree (as I did for the hard-coded values) but then I would need a way to fetch the data (including its hierarchy) from the datasources within the code of the event.
Can you pls also give some hints here how this can be achieved?
Many thanks in advance,
Andreas
Re: how to populate a treeviewcontrol?
Hello.
Unfortunately, it's impossible to get data this way. The Start mode property set how the form should be displayed but not when it will be shown.
You should prepare the data on your side.
Thank you.
Unfortunately, it's impossible to get data this way. The Start mode property set how the form should be displayed but not when it will be shown.
You should prepare the data on your side.
Thank you.