Link to home
Create AccountLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

adding a node to the selected node of a treeview

Hi,

I have this:

But i get the errors at line 7:
->The best overloaded method match for 'System.Windows.Forms.TreeNodeCollection.Add(string, string)' has some invalid arguments
->Argument 1: cannot convert from 'System.Windows.Forms.TreeNode' to 'string'      

Who can help me?

P      
string NewText = "";
            if (InputBox.Show("New Folder", "Folder Name", ref NewText, validation) == DialogResult.OK)
            {
                TreeNode n = new TreeNode();
               // MessageBox.Show(NewText);
                TreeNode n2 = tvNotes.SelectedNode;
                n.Nodes.Add(n2, NewText);
            }

Open in new window

Avatar of mkobrin
mkobrin

Try
n.Nodes.Add(n2.ToString(), NewText);
or
n.Nodes.Add(Convert.ToString(n2), NewText);
or
n.Nodes.Add(n2.Text, NewText);
SOLUTION
Avatar of mkobrin
mkobrin

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Peter Kiers

ASKER

I have this now, its error free but it does not work:


            string NewText = "";
            if (InputBox.Show("New Folder", "Folder Name", ref NewText, validation) == DialogResult.OK)
            {
                TreeNode n = new TreeNode();
                TreeNode n2 = tvNotes.SelectedNode;
                n.Nodes.Add(n2.Text, NewText);
            }

Do you know perhaps why?

p.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Oke thanx.