System.Web.UI.WebControls.TreeNode.ShowCheckBox Property

Gets or sets a value that indicates whether a check box is displayed next to the node.

Syntax

[System.ComponentModel.DefaultValue(null)]
public Nullable<bool> ShowCheckBox { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

The System.Web.UI.WebControls.TreeView control allows you to display a check box next to a node's image. Use the TreeNode.ShowCheckBox property to show or hide the check box for the current node.

Although the TreeNode.ShowCheckBox property can be used to display check boxes, it is more common to use the TreeView.ShowCheckBoxes property of the System.Web.UI.WebControls.TreeView control. The TreeView.ShowCheckBoxes property, however, affects every node type specified by the property; therefore, the TreeNode.ShowCheckBox property is often used to override that setting for an individual node.

Since the TreeView.ShowCheckBoxes property is a tri-state property, the following C# code snippet causes a compile error:

Example

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
if (TreeView1.Nodes[0].Expanded)
{
// some work here 
}
}

While VB.Net implicitly casts the Boolean value to a NullableBoolean, C# does not. Therefore, it is a best practice to explicitly check the state of the property. For example, the following code examples in Visual Basic and C# explicitly test the value of the TreeNode.Expanded property.

The following Visual Basic code example explicitly tests the value of the TreeNode.Expanded property. This example tests if the TreeNode.Expanded property is set to True; therefore Nothing and False fall through the If statement.

Example

If TreeView1.Nodes(0).Expanded = True Then 'some work hereEnd IF

This C# code example explicitly tests the value of the TreeNode.Expanded property. This example tests if the TreeNode.Expanded property is set to True; therefore Null and False fall through the If statement.

Example

if( TreeView1.Nodes[0].Expanded == true ) { //some work here}

The value of this property is stored in view state.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0