Hi,
I am pretty new with UltraTree. Do you by any chance have a sample code that shows to how to create one?
I want to create a tree similar to the below example:
Name age height
+Joe 25 5'11
+John 21 6'5
name drilldown/expansion when user clicks to plus sign button.
Name Age Height
+ Joe Lee 21 5'7
+ Joe Tow 22 6'2
if user now clicks on Joe Lee, they can expand further.
Thanks
Joe
Hi Joe,
The easiest way to do this is to bind the tree to a DataSource, like a DataSet or an UltraDataSource. Is that what you want to do?
Or are you trying to populate the tree in code without a DataSource?
Either way, there are samples installed with NetAdvantage that do this, as well as step-by-step instructions in the documentation.
Yes, I am trying to populate the tree in code. Do you have the link to this documentation?
private void Form1_Load(object sender, EventArgs e) { UltraTreeColumnSet rootColumnSet = this.ultraTree1.ColumnSettings.ColumnSets.Add("root"); UltraTreeNodeColumn lastNameColumn = rootColumnSet.Columns.Add("Last Name"); UltraTreeNodeColumn firstNameColumn = rootColumnSet.Columns.Add("First Name"); this.ultraTree1.NodeLevelOverrides[0].ColumnSet = rootColumnSet; UltraTreeColumnSet contributionColumnSet = this.ultraTree1.ColumnSettings.ColumnSets.Add("Contribution"); UltraTreeNodeColumn yearColumn = contributionColumnSet.Columns.Add("Year"); yearColumn.DataType = typeof(int); UltraTreeNodeColumn initialColumn = contributionColumnSet.Columns.Add("Initial"); initialColumn.DataType = typeof(decimal); UltraTreeNodeColumn annualColumn = contributionColumnSet.Columns.Add("Annual"); annualColumn.DataType = typeof(decimal); UltraTreeNodeColumn expectedColumn = contributionColumnSet.Columns.Add("Expected"); expectedColumn.DataType = typeof(decimal); UltraTreeColumnSet personInfoColumnSet = this.ultraTree1.ColumnSettings.ColumnSets.Add("Personal Information"); UltraTreeNodeColumn addressColumn = personInfoColumnSet.Columns.Add("Address"); UltraTreeNodeColumn cityColumn = personInfoColumnSet.Columns.Add("City"); UltraTreeNodeColumn stateColumn = personInfoColumnSet.Columns.Add("State"); UltraTreeNodeColumn zipColumn = personInfoColumnSet.Columns.Add("Zip"); UltraTreeNode rootNode = this.ultraTree1.Nodes.Add(); rootNode.Cells["Last Name"].Value = "George"; rootNode.Cells["First Name"].Value = "John"; UltraTreeNode contributionLabelNode = rootNode.Nodes.Add(); contributionLabelNode.Text = "Contribution"; contributionLabelNode.Nodes.Override.ColumnSet = contributionColumnSet; UltraTreeNode contributionNode = contributionLabelNode.Nodes.Add(); contributionNode.Cells["Year"].Value = 2004; contributionNode.Cells["Initial"].Value = 58M; contributionNode.Cells["Annual"].Value = 98M; contributionNode.Cells["Expected"].Value = 500M; contributionNode = contributionLabelNode.Nodes.Add(); contributionNode.Cells["Year"].Value = 2005; contributionNode.Cells["Initial"].Value = 0M; contributionNode.Cells["Annual"].Value = 25M; contributionNode.Cells["Expected"].Value = 1000M; UltraTreeNode personalInfoLabelNode = rootNode.Nodes.Add(); personalInfoLabelNode.Text = "Personal Information"; personalInfoLabelNode.Nodes.Override.ColumnSet = personInfoColumnSet; UltraTreeNode personalInfoNode = personalInfoLabelNode.Nodes.Add(); personalInfoNode.Cells["Address"].Value = "124 Hunter Street"; personalInfoNode.Cells["City"].Value = "Atlanta"; personalInfoNode.Cells["State"].Value = "Georgia"; personalInfoNode.Cells["Zip"].Value = "56487"; this.ultraTree1.ExpandAll(); }
Thanks =).
How do i manually change the Ultratree column width?
lastNameColumn.LayoutInfo.PreferredLabelSize = new Size (300, 0);
Would you be able to provide a sample on how to create a tree view similar to the attached image?
It looks like this is a screen shot of our existing sample. So what is it you want to do that the sample is not already doing?
To achieve something like this without data binding, you just have to create one ColumnSet (since the columns are the same on every level) and assign it to the tree.ColumnSettings.RootColumnSet.Then set the ViewStyle to OutlookExpress and add the nodes the same way I did in my sample code above.
It depends what you mean by "grid lines". You are probably looking for the ColumnSet.BorderStyleCell property.
Thanks Mike! Is it possible to add grid lines to the outlookexpress view style?
Mike Saltzman said: To achieve something like this without data binding, you just have to create one ColumnSet (since the columns are the same on every level) and assign it to the tree.ColumnSettings.RootColumnSet.Then set the ViewStyle to OutlookExpress and add the nodes the same way I did in my sample code above.
The sample code you provided shifts the column headers rightward when user expands the child nodes. I would like the columns to be static(i.e every nodes have the same column headers and it doesnt shift rightward when user expands the nodes).
I beleive I answered your question above. You might not have seen it, since I edited my post after my initial reply.