473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if (treeView1.Nodes.Count > 0)
{
if (treeView1.SelectedNode != null)
{
if (treeView1.SelectedNode.IsEditing)
{
MessageBox.Show("You are editing another
node");
return;
}
}
}

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

}

private void treeView1_AfterLabelEdit(object sender,
System.Windows.Forms.NodeLabelEditEventArgs e)
{
if (e.Label == null)
{
MessageBox.Show("can't be blank (label = null)");
e.CancelEdit = true;
e.Node.BeginEdit();
}
else
if (e.Label.Length == 0)
{
MessageBox.Show("can't be blank (length = 0)");
e.CancelEdit = true;
e.Node.BeginEdit();
}
}

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 3104

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

Similar topics

1
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...
0
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...
3
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...
0
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...
77
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...
9
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 =...
2
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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,...

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.