button event vb.net vs. C# please help.

button event vb.net vs. C# please help.

Anonymous
Not applicable
590 Views
2 Replies
Message 1 of 3

button event vb.net vs. C# please help.

Anonymous
Not applicable
New to C#

I have this code in vb.net and am trying to get this to work in C# can anyone please help.
vb.net code:

Private WithEvents my_button1 As Inventor.ButtonDefinition

Private Sub my_button1_OnExecute(ByVal Context As Inventor.NameValueMap) Handles my_button1.OnExecute

MsgBox("You Clicked Me")

End Sub

C# code:

private Inventor.ButtonDefinition my_button1;

How do I declare the button event?

private void my_button1_Onexecute(NameValueMap context)
{
//show messagebox
MessageBox.Show("You Clicked Me");
}

Regards.
Kent boettger Edited by: Kent_boettger on Mar 26, 2010 6:19 PM
0 Likes
591 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
If you take a look at this post, there's a section called "Reacting to
events in C#". Hopefully that will help.

http://modthemachine.typepad.com/my_weblog/2008/10/converting-vba-auto-macros-to-an-add-in.html

--
Brian Ekins
Inventor API Product Designer
http://blogs.autodesk.com/modthemachine
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thank you Brian for your quick reply to my questing, by the way you have a great site.

I did it like this and it works fine, but is this the right way? And another question is? On your site you do at cleanup of the event at the end. Is this necessary in this case?

m_csharpBtn1.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(m_csharpBtn1_Onexecute);

private void m_csharpBtn1_Onexecute(NameValueMap context)
{
//show messagebox
MessageBox.Show("You Clicked Me");
}

Regards.
Kent boettger.
0 Likes