I am having problems adding data to the UltraTree when the view style is in outlook express. I think the problem is that I am not quite sure how to use the UltraTreeColumnSet. Are there examples in adding data to the ultra tree?
Below is a snippet of my code, the error occurs in the bold line where I am setting the cell value for a child node. I am able to set the cell value of the parent node, but I get an error for the child node. I get a runtime error "Object reference not set to an instance of an object"
DataTable dataTable = InitializeTable(); UltraTreeColumnSet rootColumnSet = InitializeColumnSet(); ultraTree.Nodes.Clear(); UltraTreeNode rootNode = ultraTree.Nodes.Add(id+ "_" + index); rootNode.Text = id; rootNode.SetCellValue(rootColumnSet.Columns["Id"],id); rootNode.SetCellValue(rootColumnSet.Columns["Description"], "description"); rootNode.SetCellValue(rootColumnSet.Columns["EU"], "EU"); UltraTreeNode childNode = new UltraTreeNode("childNode"); try { childNode.Text = "hello"; childNode.SetCellValue(rootColumnSet.Columns["Id"], "hello"); childNode.SetCellValue(rootColumnSet.Columns["Description"], "desc"); childNode.SetCellValue(rootColumnSet.Columns["EU"], "eu"); } catch (Exception e) { MessageBox.Show(e.Message); } rootNode.Nodes.Add(childNode);
private UltraTreeColumnSet InitializeColumnSet() { DataTable dataTable = InitializeTable(); UltraTreeColumnSet rootColumnSet = ultraTree.ColumnSettings.RootColumnSet; foreach (DataColumn dataColumn in dataTable.Columns) { UltraTreeNodeColumn column = rootColumnSet.Columns.Add(dataColumn.ColumnName); column.DataType = dataColumn.DataType; } return rootColumnSet; } private DataTable InitializeTable() { // Create a DataTable DataTable dataTable = new DataTable(); // Add some columns dataTable.Columns.Add( "Id", typeof(string) ); dataTable.Columns.Add( "Description", typeof(string) ); dataTable.Columns.Add( "EU", typeof(string) ); return dataTable; }
Any help is appreciated!!
Jaime
I figured out the problem. The problem was with using the override.columnSet
Can you elaborate on how you fixed this problem, I am not getting an error when setting the values however when I run the application none of the columns are displayed. I have set the RootColumnSet as the Column Set that I want and I can add the values of the cells and the nodes just fine but when displaying it looks like a standard treeview instead of an outlookstyle treeview and the values of the cells are not being displayed.