Windows Develop Bookmark and Share   
 index > Windows Forms General > how to set length on a treeview node name?
 

how to set length on a treeview node name?

I have a treeview and I have a naming constraint on each node's name can not exceed 10 chars long. Currently, user can click on a node and change its name to over 10 characters but in the code we truncate the rest. I was wondering if there's a attribute some where on the treeview that I set the maxlength like I can do for a regular textBox? This way, users can only type in 10 charaters in the treeview node.

thanks.
  • Moved byTaylorMichaelLMVPTuesday, July 14, 2009 8:20 PMNot IDE related (From:Visual C# IDE)
  •  
queandans  Tuesday, July 14, 2009 8:15 PM
No. There is nothing in the "out of the box" TreeView control that does this.

You could, however, create a user control that inherits from a TreeView control and try to build this yourself.

Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Tuesday, July 14, 2009 9:29 PM
Implement the AfterLabelEdit event handler to verify the user's input. For example:

private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) {
if (e.Label.Length > 10) e.CancelEdit = true;
}


Hans Passant.
nobugz  Wednesday, July 15, 2009 2:00 PM
No. There is nothing in the "out of the box" TreeView control that does this.

You could, however, create a user control that inherits from a TreeView control and try to build this yourself.

Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Tuesday, July 14, 2009 9:29 PM
Implement the AfterLabelEdit event handler to verify the user's input. For example:

private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) {
if (e.Label.Length > 10) e.CancelEdit = true;
}


Hans Passant.
nobugz  Wednesday, July 15, 2009 2:00 PM

You can use google to search for other answers

Custom Search

More Threads

• Update/Refresh tableadapters
• .NET console app Executable won't read file when run from a server
• ComboBoxStyle
• mapping a data value to a color
• .NET LicenseProvider references?
• Decisions and Conditions -summary button
• Normal text and italic in a single line in msWord using c#
• Button pressed past text into textbox
• Windows Forms : Hide and Show
• How to Enumerating the Serialports automatically which are exist in the system.