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 (Full path, Back color, checked, is Editing, is Selected) using “Tree Node class” in VB and C# (.net 2.0). Part 2

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

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

 

To understand this article more read the part1 of this article.
Full Path:
If you want to get the full path of a node from its root or parent, for this purpose we have a property named full path this property returns names of all the nodes from which current node is related and sequence show the path. It returns it as a string.
Write the following code.
C#
string str;
str = obj.FullPath;
MessageBox.Show(str);
VB
Dim str As String
str = obj.FullPath
MessageBox.Show(str)
This simple code gets the full path of a current node from root.
Back Color:
You can also set or get the color of a particular node which can make easy for you to distinguish the nodes. For this purpose we have a property named back color. This property takes and returns the color.
Set:
Write the following code.
C#
obj.BackColor =Color.Blue;
VB
obj.BackColor =Color.Blue
This simple code sets the back ground color of node.
Get:
Write the following code.
C#
string str;
str = obj.BackColor.ToString();
MessageBox.Show(str);
VB
Dim str As String
string str;
str = obj.BackColor.ToString()
MessageBox.Show(str)
This simple code gets the background color of a node.
Checked:
If you want to get or set that particular node is in checked state or not for this purpose we have a property checked. This property returns and gets the Boolean value. If it is true means node is checked. If the value is false means it’s not checked.
Set:
Write the following code.
C#
bool b;
b = true;
obj.Checked = b;
 
 VB
Dim b As Boolean
b = true
obj.Checked = b
This simple code sets the checked state of node.
Get:
Write the following code.
C#
bool b;
b = obj.Checked;
string str;
str = b.ToString();
MessageBox.Show(str);
VB
Dim b As Boolean
b = obj.Checked
Dim str As String
str = b.ToString()
MessageBox.Show(str)
This simple code gets the checked state of node.
Is Editing:
If you want to know that the node is in editing state or not for this purpose we have a property named is editing. This property returns the Boolean value. If value is true then it means that node is in editing state other wise node is not in editing state.
Now write the following code.
C#
bool b;
b = obj.IsEditing;
string str;
str = b.ToString();
MessageBox.Show(str);
VB
Dim b As Boolean
b = obj.IsEditing
Dim str As String
str = b.ToString()
MessageBox.Show(str)
This simple code gets that node is in editing state or not.
Is Selected:
If you want to know that the node is in selected or not for this purpose we have a property named is selected. This property returns the Boolean value. If value is true then it means that node is selected other wise node selected.
Now write the following code.
C#
bool b;
b = obj. IsSelected;
string str;
str = b.ToString();
MessageBox.Show(str);
VB
Dim b As Boolean
b = obj. IsSelected
Dim str As String
str = b.ToString()
MessageBox.Show(str)
This simple code gets that node is selected or not.
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 how we can make a tree node and set node properties using “Tree Node class” in VB and C# .net 2.0.

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to make tree node (Name, Text, Tag, First Node, Parent) using “Tree Node class” in VB and C# (.net 2.0). Part 1

Disclaimer - Privacy
© 2002-2017 DevASP.net