Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Programmatically Select a Node in TreeView.

Total Hit ( 3283)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


This is very easy but tricky. By default HideSelection property of treeview is true. So it confuses many programmer. When you use Treeview.Selected=True and HideSelection is True then it wont show the selection even though node is selected. Check the following example for that

Click here to copy the following block
Private Sub Command1_Click()
  TreeView1.Nodes("b1").Selected = True
  '///////////////////////////////////////////////
  'or
  '///////////////////////////////////////////////
  'Set TreeView1.SelectedItem = TreeView1.Nodes("b1")
  
  '///////////////////////////////////////////////
  '//Starting Label Edit with node select
  'TreeView1.StartLabelEdit
  '///////////////////////////////////////////////
End Sub

Private Sub Form_Load()
  TreeView1.HideSelection = False

  TreeView1.Nodes.Add , , "root", "root"
  TreeView1.Nodes.Add "root", tvwChild, "a1", "a1"

  TreeView1.Nodes.Add "a1", tvwChild, "a1-1", "a1-1"
  TreeView1.Nodes.Add "a1", tvwChild, "a1-2", "a1-2"

  TreeView1.Nodes.Add "root", tvwChild, "b1", "b1"
  TreeView1.Nodes.Add "b1", tvwChild, "b1-1", "b1-1"
  TreeView1.Nodes.Add "b1", tvwChild, "b1-2", "b1-2"

  TreeView1.Nodes.Add "root", tvwChild, "c1", "c1"
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.