newbye : assign action to click event on treeview node

A

arr uba

Hi there,
i'm a newbye in C# and, as all IDE's enthusiasts, I find very easy to
visually drag and drop objects on my canvas, but now I need to add some code
to click event...

I've just insert a node-treeview object, and now when clicking on each item
node I wish to assign a action (open file directory, print report, open
database for editing, etc.)

So, I'm trying to use the: TreeView.NodeMouseClick Event

C# help guide suggests the following code (with appropriate change on my
object name):
void treeView1_NodeMouseClick(object sender,
TreeNodeMouseClickEventArgs e)
{
textBox1.Text = e.Node.Text;
}
My problem is that neither Intellisense detects my own objects and neither
they are recognized by the IDE (mv#5), so coding is useless...So I'm adding
just a simple code as follows:void trvSubProjects_NodeMouseClick(object
sender,TreeNodeMouseClickEventArgs e) { MessageBox("hello"); }
But I get an error message like this: Error 1
'System.Windows.Forms.MessageBox' is a 'type' but is used like a 'variable'
C:\myDocuments\Visual Studio 2005\Projects\Form1.csI'm sure it is a very
simple issue...but I can't figure it out.I appreciate any help.Thanks.AR
 
M

Martin Honnen

arr said:
So I'm adding
just a simple code as follows:void trvSubProjects_NodeMouseClick(object
sender,TreeNodeMouseClickEventArgs e) { MessageBox("hello"); }
But I get an error message like this: Error 1
'System.Windows.Forms.MessageBox' is a 'type' but is used like a 'variable'

You want
MessageBox.Show("hello");
 
M

Martin Honnen

arr said:
So I'm adding
just a simple code as follows:void trvSubProjects_NodeMouseClick(object
sender,TreeNodeMouseClickEventArgs e) { MessageBox("hello"); }
But I get an error message like this: Error 1
'System.Windows.Forms.MessageBox' is a 'type' but is used like a 'variable'

You want
MessageBox.Show("hello");
 

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