473,487 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Create 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 5841
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
1300
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
8023
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...
2
8286
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...
4
2972
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...
9
2799
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...
1
2949
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): ...
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...
3
4316
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...
0
2465
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...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
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...
0
7132
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,...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
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,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
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...
0
1381
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 ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.