TreeView supports integration with the Expression Editor control. When integrated with Expression Editor, expressions can be used to perform operations such as column calculation over the data in TreeView. These expressions can be used on all the node levels available in the TreeView control.
To integrate Expression Editor with the TreeView, you need to use ExpressionInfo property of C1TreeColumn class, which contains information about expressions. These expressions can be set for columns using Expressions property of ExpressionInfo class.
The following image shows the TreeView control integrated with Expression Editor.
The ExpressionInfo class provides various other properties listed below that can be used to manipulate expressions in TreeView control. These properties can be used to add, edit, or delete expressions on any of the node levels available in TreeView.
Property | Description |
---|---|
AllowAddNew | Indicates the ability to add node level expression |
AllowDelete | Indicates the ability to remove node level expression |
AllowEdit | Indicates whether the expressions of this column can be edited by clicking the Expression Editor icon in the column header |
ExpandLastExpression | Indicates whether the last expression expand to all subsequent levels of the TreeView even if the expression is not defined for them |
The following code demonstrates integration of TreeView with Expression Editor. In this code, expression is used on the fifth column of the TreeView control which contains two levels. Here, we have added an expression for the second level only.For this, we set our expression to the second item of the Expressions array, and set the first item as empty.
C# |
Copy Code
|
---|---|
private void Form1_Load(object sender, EventArgs e) { this.categoriesTableAdapter.Fill(this.c1NWindDataSet.Categories); this.productsTableAdapter.Fill(this.c1NWindDataSet.Products); c1TreeView1.BindingInfo.DataSource = c1NWindDataSetBindingSource; c1TreeView1.Columns[4].ExpressionInfo.Expressions = new string[] { "", "[UnitPrice]*([UnitsInStock]+[UnitsOnOrder])" }; c1TreeView1.Columns[4].ExpressionInfo.AllowEdit = new bool[] { true, true }; c1TreeView1.Columns[4].ExpressionInfo.AllowAddNew = true; c1TreeView1.Columns[4].ExpressionInfo.AllowDelete = true; } |