'宣言 Public Event ColumnSetGenerated As ColumnSetGeneratedEventHandler
public event ColumnSetGeneratedEventHandler ColumnSetGenerated
イベント ハンドラが、このイベントに関連するデータを含む、ColumnSetGeneratedEventArgs 型の引数を受け取りました。次の ColumnSetGeneratedEventArgs プロパティには、このイベントの固有の情報が記載されます。
プロパティ | 解説 |
---|---|
ColumnSet | 新しく生成された UltraTreeColumnSet を返します。 |
データバインドされたノードまたはノードのコレクションを作成する結果として、ツリーが新しい UltraTreeColumnSet を生成する時にイベントが発生します。
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
using Infragistics.Win.UltraWinTree; private void ultraTree1_ColumnSetGenerated(object sender, Infragistics.Win.UltraWinTree.ColumnSetGeneratedEventArgs e) { // 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. switch (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; break; 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; break; case "InvoiceDetails": case "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 = this.uddProducts; // Since the ProductID column will be showing names instead of IDs // change the caption. e.ColumnSet.Columns["ProductID"].Text = "Product Name"; break; 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"; break; default: Debug.Assert(false, "This code should never be reached"); break; } }