Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to make tree node (Previous Visible Node, Begin edit, stop edit, collapse) using “Tree Node class” in VB and C# (.net 2.0). Part 4

Author: Zunnair
Download Source Code : 895_Tree Node.zip

In this simple article you will learn that how we can make a tree node, setting node properties and use of functions using “Tree Node class” in VB and C# .net 2.0.

 

To understand this article more read the part1, part2 and part3 of this article.
Previous Visible Node:
If you want to know the previous visible node from the particular node for this purpose we have a property named previous visible node. This property returns the object of tree node class. This object has the information about the previous visible node.
Now write the following code.
C#
TreeNode pv = new TreeNode();
pv = obj.PrevVisibleNode;
string str;
str = pv.Name;
MessageBox.Show(str);
VB
Dim pv As New TreeNode()
pv = obj. PrevVisibleNode
Dim str As String
str = pv.Name
MessageBox.Show(str)
This simple code gets the previous visible node from a particular node.
Begin Edit:
If you want to begin the editing of a particular node label for this purpose tree node class has a function named begin edit (). This function takes and returns nothing. To use this function first you have to set the tree view control label edit property true.
To demonstrate make a window application drag a button and tree view control. Add the node in control.
Now write the following code on button click event:
C#
private void btn_Start_Click(object sender, EventArgs e)
        {
            obj.BeginEdit();
            MessageBox.Show("edit has started");
        }
VB
Private Sub btn_Start_Click(ByVal sender As Object, ByVal e As EventArgs)
        obj.BeginEdit()
        MessageBox.Show("edit has started")
    End Sub
This simple code begins the label edit of a particular node.
Stop Edit:
If you want to stop the editing of a particular node label for this purpose tree node class has a function named end edit (). This function takes a Boolean value which decides that the label editing should be end without save or not. If you want to save the changes than pass false else pass true. This function returns nothing. To use this function first you have to set the tree view control label edit property true.
To demonstrate make a window application drag a button and tree view control. Add the node in control and start the edit.
Now write the following code on button click event:
C#
private void btn_Stop_Click(object sender, EventArgs e)
        {
            obj.EndEdit(true);
            MessageBox.Show("Edit Has been stopped");
        }
VB
Private Sub btn_Start_Click(ByVal sender As Object, ByVal e As EventArgs)
        obj.EndEdit()
        MessageBox.Show("Edit Has been stopped ")
    End Sub
This simple code stops the label edit of a particular node.
Collapse Node:
If you want to collapses a particular node for this purpose tree node class has a function named collapse (). This function has one overloaded method.
First Method:
This function takes and returns nothing and collapses the node and its child.
To demonstrate make a window application drag a button and tree view control. Add the node.
Now write the following code on button click event:
C#
private void btn_collapse_Click(object sender, EventArgs e)
        {
            obj.Collapse();
        }
VB
Private Sub btn_collapse_Click(ByVal sender As Object, ByVal e As EventArgs)
        obj.Collapse()
    End Sub
This simple code collapses a node and its child.
Second Method:
This function takes a Boolean value which decides that the child of a node should remain in their current state or should be collapse. If you pass true it means that child should remain in their current state else they should be collapsed also. This function returns nothing.
To demonstrate make a window application drag a button and tree view control. Add the node.
Now write the following code on button click event:
C#
private void btn_collapse_Click(object sender, EventArgs e)
        {
            bool b;
            b = true;
obj.Collapse(b);
        }
VB
Private Sub btn_collapse_Click(ByVal sender As Object, ByVal e As EventArgs)
bool b;
b = true;       
obj.Collapse(b)
    End Sub
This simple code collapses a node but remains its child in current state.
Now write the following code on FORM LOAD event:
C#
private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "DEVASP TREE NODE APPLICATION";
        }     
VB
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        Me.Text = "DEVASP TREE NODE APPLICATION"
    End Sub
 
This simple article tells that that how we can make a tree node, setting node properties and use of functions using “Tree Node class” in VB and C# .net 2.0.
   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to make tree node (is Expanded, is Visible, Last node, Level, Next Node, Next Visible Node) using “Tree Node class” in VB and C# (.net 2.0). Part 3

Disclaimer - Privacy
© 2002-2017 DevASP.net