Expression Editor for WinForms | ComponentOne
Working with Expression Editor / Integration with TreeView
In This Topic
    Integration with TreeView
    In This Topic

    Expression Editor supports integration with the TreeView control. When integrated with TreeView, Expression Editor enables using expressions on TreeView and performs operations such as column calculation over its data. These expressions can be added, edited, or removed 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 exhibits Expression Editor integrated with the TreeView control.

    Expression Editor TreeView

    The following code demonstrates integration of Expression Editor with TreeView. 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])" };
     }