Maurice Freitag Maurice Freitag - 1 year ago 82
C# Question

TreeNode BeginEdit() doesn't save any text

I added a treeview to my main form, right-clicking opens a contextmenu where you can add new nodes to the tree (in this case categories).

It creates, then adds the node and calls BeginEdit()...

private void addCategoryToolStripMenuItem_Click(object sender, System.EventArgs e)
var category = new TreeNode();


...and then this:

From the info I gathered this should work just fine, howeeeeever:

enter image description here
Any ideas? :)

Just a kind of extension: the problem doesn't lie within BeginEdit(), I can't edit the label at all. I still don't know why, but now I know I need to look somewhere else.

Answer Source

Your initial node can't be blank, so fill it with some kind of text:

var category = new TreeNode("abc");