views:

83

answers:

2

A custom windows form control named 'tweet' is in a dll. The custom control has couple of basic controls to display a tweet. I add this custom control to my main application. This custom control has a button named "retweet", when some user clicks this "retweet" button, i need to send some message to the main application. Unfortunately the this tweet control has no idea about this main application (both or in their own namespaces)

How can i send messages from this custom control to the main application?

+2  A: 

One way is to add an event to your control and have the control fire that event when it needs to send a message. The main form can add an event handler when it creates the form and be notified of the messages. This way your control does not need to have any hard-coded reference to the main form.

Mark Byers
Mark, Thanks for the reply. It seems to be a good idea.
zer0c00l
+1  A: 

You raise and handle the event. See the code sample on this page (you might have to choose the language on the page to be C#)

http://msdn.microsoft.com/en-us/library/9aackb16(v=VS.71).aspx

Raj Kaimal