473,811 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# - Form: Modify TreeView Name during Runtime

3 New Member
Hey guys, i'm still working on that chat program, and i was wondering if there was a way to modify the name of already created nodes during runtime.

i know that you can create them but i don't know how to edit the name of created ones.

thanks.
Aug 8 '08 #1
3 5865
cloud255
427 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. node.name = "new name";
take note that the name of the node is not displayed, to change that use:

Expand|Select|Wrap|Line Numbers
  1. node.name = "display text";
the easiet way do do this kind of thing is to type the name of the control you want to edit followed by a "." and then just use intellisense...
Aug 12 '08 #2
roucha
3 New Member
there is nothing that is called "node" hence i can't do

node.name = "hello";

i have already tried this, thats why i'm asking here because i've tried everything that i knew.
Aug 16 '08 #3
cloud255
427 Recognized Expert Contributor
there is nothing that is called "node" hence i can't do

node.name = "hello";

i have already tried this, thats why i'm asking here because i've tried everything that i knew.
If the control exists at runtime, you can access its properties.

So somewhere in your code you create all these dynamic contols, after that, you can go:

Expand|Select|Wrap|Line Numbers
  1. Controls["controlName"].Text = "Display Text";
Whether you create the TreeView at runtime or not, you should have given it a name:

you can then loop through all your dynamically created nodes which live in this TreeView and access the "Text" property of the appropriate one:

Expand|Select|Wrap|Line Numbers
  1. foreach (TreeNode node in TreeView1.Nodes)
  2.             {
  3.                 if(node.Tag.Equals(somevalue))
  4.                 {
  5.                        node.Text = "New Value";
  6.                 }
  7.             }
You need to give some sort of unique value to each node you create, something meaningful which you can access, otherwise there is no way for you to distinguish between the nodes.

Good luck, hope this was helpful
Aug 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1326
by: John Bailo | last post by:
I am trying to debug a form in VS.NET 2003 I set some breakpoints for a treeview click event. This is what happens: The form loads. I click a node in treeview The break point is hit
2
8048
by: serge calderara | last post by:
dear all, Is there an easy way to bind a treeview control with an XML object as datasource? In a similar way as the dataset is doing, and build columns accroding to XML node, I could imagine a treeview which build its notes accordind to XML object too how can I do that?
2
8317
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am showing one transparent form (form3) when ever user preseed left mouse button. 3) The form3 has one transparent user control (usercontrol2) that paints circles. That measn the circles will show on top the usercontrol1 image. 4) The form3 border style...
4
2994
by: Weinand Daniel | last post by:
i'd like to monitor changes of the "Control.Name" porperty during designtime. if the user changes the name in designer my event musst fire. i have created a own button control. with an event NameChange. during runtime it works fine. if the name of the control has changed the event is fireing. (for example: designtime name of the button is btnOk, on a second button
9
2827
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
1
2970
by: Alexandru Nedelcu | last post by:
Hi!!! I'm trying to add a UserControl created using the Page.LoadCotnrol("test.ascx") method to a Page's Control collection and the exception I get is ( the complete stack trace): System.Web.UI.ControlCollection.Add(Control child) Akela.WebFramework.Design.TreeView.TreeNode.LoadUserControl() in d:\projects\akelahr\localsourcesafe\akelahrenterprise\akela.webframework\design\treeview\treenode.cs:451
3
305
by: Christian Hamel | last post by:
Hello. Here's my problem. I have a Treeview with many options and in the TAG property of these nodes, I have a form name (frmDetail, frmheader, etc..). In the doubleclick event of my Treeview, I would like to open the proper form based on the value in the TAG property. This must be easy but I can't find the way :( Any help would be appreciated. Thanks.
3
4338
by: avanti | last post by:
Hi, I have an application that has a tag hierarchy that is pulled from the database and displayed in a treeview. I want to enable the user to add nodes (tags) to this treeview at runtime and give them any names. E.g. After "Add tag" button is clicked, the treeview has an empty node added at a specific location and the name can be given by the user. Is it possible?
0
2490
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to render it within my control it crashes and burns. I've even tried placing it within another control (a PlaceHolder) and tried to render the PlaceHolder to no avail. Any ideas on how to fix this problem? Here's my code:
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.