UltraTree bound to 4 hierarhical DataTables with relationships. All columns visible for clarity. I have not altered col.LayoutInfo.OriginX or anything else. 1st table has 6 columns. Linked are images of typed DataSet and 2 ultraTree1.ViewStyles (default, and OutlookExpress) on Pinterest (may need to download to see full size): https://pin.it/ac3ykt2ngnxau2
A. ViewStyle = default (all columns on all rows are in the same order as the DataTable
B. ViewStyle = OutlookExpress (some discrepancies in column order)
Row[1].Col[0] = 66 but should be 1070
Row[2].Col[1] = "CD33" but should be "10010"
Column order for all DataTable as follows (deployed version will hide column 0 and 3,4,5,6,7, etc.)
[0] = primary key
[1] = displayed value (string). (should be = column.ColumnSet.ExpansionIndicatorColumn.Key)
[2] = status (string)
Almost everything displays as expected except the two items mentioned under ViewStyle = OutlookExpress
('m not understanding what determines the default column order here or why they changed between the default ViewStyle and the OutlookExpress ViewStyle? It's clearly not the order in the DataTable.
thanks, Mark
Hi Mark,
Thank you for posting in our forums!
One of our developers provided the following information on what is happening here. Please see his comments below:
OutlookExpress is basically for homogenous data where every band has the same columns. That’s not the case here, so it’s a little odd to use OutlookExpress style for this data. But I can see that the data is sort’ve the same in each band except for the parent key field.
So what’s happening here is that the root band has a column called “Campaign_ID” and the child band has a column with the same name. The tree is, quite naturally, assuming that these are the same and should be linked up since they have the same name/key.
Since the columns don’t really match up, the customer will have to manually link the columns in the child bands to the correct column in the root band. At least for the cases where the names are not already the same. You do this via the MapToColumn property on the column. On the child band column, you specify the key of the column in the root band that determines where the child column will display.
But there is also some weirdness here because the number of columns doesn’t match up. And I don’t know what the Experiment_Type file should map to in the root band. So OutlookExpress ViewStyle really doesn’t make a lot of sense for this data structure.
I attached a sample here that shows how to do the mapping.
0247.WindowsFormsApplication53.zip
Please let me know if you need further assistance and I will be glad to help.
Understood, and the column remapping works perfectly. I am enclosing a code snippet for others to see.
private void treeView1_ColumnSetGenerated(object sender, ColumnSetGeneratedEventArgs e) { UltraTreeColumnSet columnSet = e.ColumnSet; switch (columnSet.Key) { case "Campaign_Experiments": columnSet.Columns["Experiment_ID"].MapToColumn = "Campaign_ID"; break; case "Experiment_Plates": columnSet.Columns["Barcode"].MapToColumn = "Campaign_Name"; break; } if (e.ColumnSet.Columns.Count > 0) { // the dataset ws tailored so the columns needed are in the same order for each table // [0] ID, [1] text to display, [2} status used for colored dot columnSet.Columns[0].Visible = false; columnSet.Columns[1].Visible = true; columnSet.Columns[1].LayoutInfo.PreferredCellSize = new System.Drawing.Size(500, 10); columnSet.Columns[2].Visible = true; columnSet.Columns[2].LayoutInfo.PreferredCellSize = new System.Drawing.Size(50, 10); int count = columnSet.Columns.Count - 1; // (last one is actually the foreign key, so use one less) for (int i = 3; i < count; i++) columnSet.Columns[i].Visible = false; } }
One statement I might dispute: "OutlookExpress is basically for homogenous data where every band has the same columns".. TreeViews I've seen have been used for hierarchical DataTables, not homogeneous data; and, it is difficult for tool consumers to know, a priori, limitations of use in the minds of the creator. Nevertheless, the solution is simple, functional, and flexible. Thank you!
Mark Bean said:One statement I might dispute: "OutlookExpress is basically for homogenous data where every band has the same columns".. TreeViews I've seen have been used for hierarchical DataTables, not homogeneous data
That's true of Tree controls in general and even UltraTree in particular - but not when using OutlookExpress ViewStyle. This style mimics OutlookExpress, which is an e-mail client and it displays e-mail threads in a hierarchy. As such, every node in the tree is an e-mail, so they all have exactly the same columns and structure.
OutlookExpress shows a single set of column headers, so it's intended for use where every level of the hierarchy has the same columns and you therefore only need a single set of headers for the entire tree.
Of course, you CAN show non-homogenous data in OutlookExpress Style. But it's a little odd, since there will be a single column header that represents different data at different levels of the hierarchy. And, as we've established here, you have to tell the tree which parent columns are linked up to which child column, since it has no way of knowing that.
I hope that clarifies things. :)
That actually makes perfect sense now, thanks.