Imports Infragistics.Win.UltraWinTree
Private Sub ultraTree1_ColumnSetGenerated(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.ColumnSetGeneratedEventArgs) Handles ultraTree1.ColumnSetGenerated
' This event will fire whenever the tree automatically generates a ColumnSet.
' The ColumnSet is not neccessarily attach to any particular group of
' Nodes at this point, so this is an appropriate place to apply appearances
' and properties that apply at a ColumnSet level.
' The Key of the generated ColumnSet will match the key of the band of data.
Select Case (e.ColumnSet.Key)
Case "Customers"
' Hide the CustomerID column.
e.ColumnSet.Columns("CustomerID").Visible = False
' Highlight FirstName and LastName columns.
e.ColumnSet.Columns("FirstName").CellAppearance.BackColor = Color.Cyan
e.ColumnSet.Columns("LastName").CellAppearance.BackColor = Color.Cyan
Case "Invoices"
' Hide the InvoiceID and CustomerID columns.
e.ColumnSet.Columns("InvoiceID").Visible = False
e.ColumnSet.Columns("CustomerID").Visible = False
' Highlight Total column.
e.ColumnSet.Columns("Total").CellAppearance.BackColor = Color.Chartreuse
' Format the Total Column as Currency
e.ColumnSet.Columns("Total").Format = "c"
' Format the InvoiceDate so it shows only the date and no time.
e.ColumnSet.Columns("InvoiceDate").Format = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
Case "InvoiceDetails", "Invoice Details"
' Note that the DataSet contains a table named "InvoiceDetails" and
' a Relationship name "Invoice Details". So there will be two
' different ColumnSets based on which one is being displayed.
' When the Invoice Details are displayed as the root, "InvoiceDetails"
' is used (since it matches the table name). When Invoice Details are displayed
' as a child band, "Invoice Details will be used (since it matches
' the Relationship name).
' Hide the DetailID and InvoiceID columns.
e.ColumnSet.Columns("DetailID").Visible = False
e.ColumnSet.Columns("InvoiceID").Visible = False
' Highlight Total column.
e.ColumnSet.Columns("Total").CellAppearance.BackColor = Color.Pink
' Format the Total Column as Currency
e.ColumnSet.Columns("Total").Format = "c"
' Assign a ValueList to the ProductID column to translate
' the ProductID into a more user-friendly product name.
' Note that UltraTree cells are not editable. The ValueList
' in this case is for the purpose of translating data values
' into display values. It will not drop down.
e.ColumnSet.Columns("ProductID").ValueList = Me.uddProducts
' Since the ProductID column will be showing names instead of IDs
' change the caption.
e.ColumnSet.Columns("ProductID").Text = "Product Name"
Case "Products"
' Hide the ProductID column.
e.ColumnSet.Columns("ProductID").Visible = False
' Highlight the Name column.
e.ColumnSet.Columns("Name").CellAppearance.BackColor = Color.Yellow
' Format the UnitCost Column as Currency
e.ColumnSet.Columns("UnitCost").Format = "c"
Case Else
Debug.Assert(False, "This code should never be reached")
End Select
End Sub