Accepting TreeView node names at runtime

A

avanti

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 give them any names. E.g.
After "Add tag" button is clicked, the treeview has an empty node added
at a specific location and the name can be given by the user.

Is it possible?

Thanks,
Avanti
 
C

Cor Ligthert [MVP]

Avanti

You mean as in Explorer with new folder etc.

I never did it and you are probably able to do it with painting.

However, that is probably a lot of work, if I could not find a sample on
Internet, than I would just open a dialoform, make it very small and nice,
possition it somewhere on the treeview and than let the user type in the
name he/she wants (TopMost).

Just my thought reading your message.

Cor
 
C

Claes Bergefall

Yes, something like this:

void AddNode(TreeNode parent)
{
TreeNode node = parent.Nodes.Add("<name>");
node.BeginEdit();
}

You have to set the TreeView's LabelEdit property to true

/claes
 
A

avanti

Great! That worked. Thanks.

Avanti Ketkar

Claes said:
Yes, something like this:

void AddNode(TreeNode parent)
{
TreeNode node = parent.Nodes.Add("<name>");
node.BeginEdit();
}

You have to set the TreeView's LabelEdit property to true

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top