Write an Article Write a Tutorial Add a Fast Code* *Fast Code might be any helpful code with brief comment
Stem Cells Blood Banks Insurances .Net Hosting Credit Cards PC Rental Business
Tutorials: ASP .NET C# .NET VB .NET Articles: ASP .NET C# .NET VB .NET Fast Code: ASP .NET C# .NET VB .NET
private void TasksNodes_Load(object sender, EventArgs e) { this.treeView1.Nodes.Add("Tasks"); try { DatabaseOperations dbopration = new DatabaseOperations(); //This class contains the logic of the Data operations DataTable myTable = dbopration.LoadTasksTable(); //Loads Tasks from the Database foreach (DataRow row in myTable.Rows) { if (!string.IsNullOrEmpty(row[1].ToString())) { TreeNode node = new TreeNode(@"Task: " + row[1].ToString()); this.treeView1.Nodes[0].Nodes.Add(node); TreeNode node2 = new TreeNode(@"FullTaskName: " + row[2].ToString()); node.Nodes.Add(node2); } } this.treeView1.Sorted = true; this.treeView1.Nodes[0].Expand(); Cursor.Position = new Point(Location.X + 30, Location.Y + 30); //Move the Mouse curser to the first Node } catch (OleDbException exp) { MessageBox.Show("Error: {0}" + exp.Errors[0].Message); } }
Now see how we are selecting the treeview node.
private void treeView1_DoubleClick(object sender, EventArgs e) { if (treeView1.SelectedNode.IsSelected) { this.SelectedTreePath = selectAllPath(this.treeView1.SelectedNode); //SelectedTreePath is a string type Variable defined in the Class this.DialogResult = DialogResult.OK; //To close the Popup Form. otherwise remove this line } } private string selectAllPath(TreeNode ThisSelectedNode) { string selcetedAbove = ThisSelectedNode.FullPath; string selectedBelow = string.Empty; foreach (TreeNode node in ThisSelectedNode.Nodes) { selectedBelow += selectedBelow + "\\" + node.Text; } return selcetedAbove + selectedBelow; }
This will close the Treeview and selected nodes Text will be copied to the SelectedPath (Which is a string variable).
Is there any way to do this in .net 1.1
your code is perfect ...
good coding
21/03/2007 07:04:00 UTC
21/03/2007 07:18:48 UTC
I working on Telerik control Rad treeview.I want to know hpow to add nodes on a particular index in treview
Help ME !
08/09/2007 01:03:02 UTC
01/10/2007 06:21:47 UTC
04/12/2007 23:35:19 UTC
25/12/2007 03:15:28 UTC
i have selected item but not display records .
they give error msg.
24/03/2008 01:35:46 UTC
30/05/2008 06:24:53 UTC