473,800 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

treeView afterLabelEdit deadly embrace

I created a Windows form and stuck a toolbar on it with one button. I
then added a treeView, docked it to the left of the form and enabled
Label Edit.

Here's the toolbar button click and after label edit event code:

private void toolBar1_Button Click(object sender,
System.Windows. Forms.ToolBarBu ttonClickEventA rgs e)
{
if (treeView1.Node s.Count > 0)
{
if (treeView1.Sele ctedNode != null)
{
if (treeView1.Sele ctedNode.IsEdit ing)
{
MessageBox.Show ("You are editing another
node");
return;
}
}
}

TreeNode nextIdea = new TreeNode("", 0, 0);
treeView1.Nodes .Add(nextIdea);
nextIdea.BeginE dit();

}

private void treeView1_After LabelEdit(objec t sender,
System.Windows. Forms.NodeLabel EditEventArgs e)
{
if (e.Label == null)
{
MessageBox.Show ("can't be blank (label = null)");
e.CancelEdit = true;
e.Node.BeginEdi t();
}
else
if (e.Label.Length == 0)
{
MessageBox.Show ("can't be blank (length = 0)");
e.CancelEdit = true;
e.Node.BeginEdi t();
}
}

Here's what happens when I click the toolbar button and then click it
again without entering anything in the new node label.

-- get message "can't be blank (label = null)"
(click ok)
-- get message "can't be blank (label = null)"
(click ok)
-- get message "can't be blank (label = null)" and 2nd node appears in
tree view with edit box around it
(click ok)
-- get message "can't be blank (label = null)" and edit box disappears
but 2nd node remains
(click ok)
-- same message and edit box reappears on 2nd node
(click ok)
-- edit box appears around 1st node as well as 2nd
(click ok)
-- edit boxes remain, message window closes

If I click anywhere on or off the form, the message window reappears. If
I close the message window, any further click produce the same behaviour.

If I click the toolbar button again, the whole thing repeats except there
are now 3 nodes in the treeView and so on.

Am I doing something wrong?

All I want to do is add nodes to a list and allow new nodes to be created
while others are still being edited.

Cheers,
..pd.
Nov 13 '05 #1
0 3129

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3656
by: Sam | last post by:
I'm having problem. I want to have a block of code run, after a user edits the label of a node, so I put the code in the event method of the afterLabelEdit event. The problem is that this code is called even before the label is finished being edited - its being called as soon as beginEdit is called. How can I have a block of code that is run only after the user finished editing?
0
1354
by: Andres Romero | last post by:
How can I catch the Key event in a treeview before the AfterLabelEdit event to catch the Escape key? My code has both events declared in the treeview, but the first executed is the afterlabeledit and I can´t process the Esc key to cancel the node label edition.
3
7788
by: bob | last post by:
Hello, the nodes in my tree view show a name and then a suffix. I want to be able to edit the name using 'label edit' but I want the suffix to be removed and then added after the edit. I try this with the events AfterLabelEdit and BeforeLabelEdit but they don't do anything. The following bit of code just has a tree view with some nodes and has BeforeLabelEdit set to change the node text to 'editing': private void...
0
1625
by: nevin | last post by:
I have a TreeView control which I progmatically (is that a word?) add a node to the root node BeginEdit() on that node and then want the user to change the name of it. Exactly as what happens when you right click in explorer and you create a new folder. My problem is that even though everything works fine, the label is not highlighted, so the user has to click inside the editing box of the label, select the text manually and then type...
77
14452
by: Tark Siala | last post by:
hi i working with TreeView in VB6, and have good Properity Named (Key) with the Key i can goto Any Node i know hes Key. but in VB.NET i can find the Key :( please tell me where i can find the key in TreeView.Net... ----------------------------------------------- Best Regards From Tark
9
1849
by: Tony | last post by:
Hello, In a textbox it is possible set charapters to upper with this property : CharacterCasing = Upper In a treeView not is possible... In Vb i set in a Event form KeyPress --> keyascii = asc(ucase(chr(keyascii)))
2
3941
by: Kela | last post by:
An interesting problem: I have a ListView with LabelEdit set to TRUE. When I change the label, I want to make some decisions as to whether the ListViewItem (that's just been edited) should stay in the ListView or not. The natural place to inspect this is in the AfterLabelEdit event... If the decision is to take the item out, I used the ListViewItem.Remove(). However - check this out: A) say that the item's index is N (indices are...
2
4541
by: Pucca | last post by:
Hi, When the user select a tree node, right click and select the "Rename" option in my context menu, I would like to create the Edit Label ability for the user. I would like to have the blinking cursor on the selected node, which will be in rectangle frame, and allow the user to edit the labe and when it loses focus or hit enter then I'll get back the newly edited/entered text of the treenode label. Can someone point me to a sample code...
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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
10501
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
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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
5469
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
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
2
3764
muto222
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.