.NET (C #) passing messages from a custom control to the main application

A custom Windows form control named "tweet" is located in a dll. The custom control has a couple of basic controls for displaying a tweet. I am adding 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 kind of message to the main application. Unfortunately this tweet control has no idea about this main app (both or in their own namespaces)

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

+2


a source to share


2 answers


One way is to add an event to your control and manage that event when it needs to send a message. The main form can add an event handler when it creates the form and is notified of messages. This way you don't need to have a hard-coded link to the main form.



+2


a source


You raise and handle the event. See sample code on this page (you may need to select the language on the page to be C #)



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

+1


a source







All Articles