:doh: :doh: 9:53 5 Feb '08 how to add a now treenode in the following code? - samidhas 11:04 4 Feb '08 i want to insert a new node regarding this code.but insert is not working.. - samidhas 10:32 4 Feb '08 how to insert a new node in a tree view programatically? - samidhas I reckon it's time to put some effort into this and be a little bit more specific with your problem.
We violated nature and our children have to pay the penalty Don't go near the water children... Johnny Cash - 1974
Simple example:
string someText = yourTextBox.Text;
TreeNode aNode = new TreeNode();
aNode.Name = "some name here";
aNode.Text = someText;
yourTreeCtrl.Nodes.Add(aNode);
You could get more browsing the MSDN articles[^], couldn't you? ;)
SkyWalker
Google "reading text file in C#", this is basic IO. It's a text file, look at the StreamReader, (or even the XmlTextReader if you really need it, though it doesn't sound like you do).
Try code model generation tools at BoneSoft.com.
samidhas wrote:
its urgent plz help meeeeeeeee
Tut tut. It's always urgent. Saying this is just plain rude and inconsiderate. Why do you think your requirements are any more urgent than all of the other posters? This is a volunteer only forum, so you have to be patient and wait for the relevant volunteers to get round to answering your questions. Pestering people and posting crap like this makes it less likely that you will get help. We get very annoyed at people with attitudes like this.
Deja View - the feeling that you've seen this post before.
My blog | My articles
Do you want to display XML file contents to a rich text box ?
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
AFAIK, you need to handle the event which fires when a node is deleted, then find the same node in the XML file and delete it. Then save the file. You can use XMLDocument class for this.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
I replied to your other thread, but you should be using the XMLDataSource and it's Save method to save the XML. I beleive you should just be able to add nodes by creating a new node entry.
// Create the new node.
TreeNode newNode = new TreeNode();
newNode.Text = row["CategoryName"].ToString();
newNode.Value = row["CategoryID"].ToString();
// Set the PopulateOnDemand property to true so that the child nodes can be
// dynamically populated.
newNode.PopulateOnDemand = true;
// Set additional properties for the node.
newNode.SelectAction = TreeNodeSelectAction.Expand;
// Add the new node to the ChildNodes collection of the parent node.
node.ChildNodes.Add(newNode);
I did a quick look and it appears you should be using the XmlDataSource for the TreeView's Datasource. There is a Save method on the XmlDataSource, so I would start there and see what you can figure out. http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.save(VS.80).aspx[^]
Have you come up with any good ideas?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon