Thursday, April 20, 2006 6:19 AM
I create two winform usercontrol, first have some filter and search fo some data. When data is located or user click on selected record in grdid i want that in other usercontrol which also have some data, display data, depends on selected record in first control.
I have this two usercontrol on one winforms. So how can establish communication between, i read that this can be done with some events or... but i can not find how to create events which can be fired also on second usercontrol. I can create only event in one control, can somebody give me some example or mybe some other posibilities how can i send to other usercontrol some data, some parameters when event is fired so that second usercontrol will refresh it is data...
thanks for any help
Saturday, April 22, 2006 5:15 AM
You could create for the first control some event for what you need (I didn't quiet understand what your first control does).
Which would be done in this way:
publicdelegate void MyEventHandler(object sender, EventArgs e); public event MyEventHandler OnMyEvent; //to raise the event: OnMyEvent(this, new EventArgs);
The second Control will have a public method called omething like Update()
Now all you have to do is to handle the 'OnMyEvent' event on your form and call the Update method to pass anything you like.
Please note that you the MyEventHandler delegate may have any signature that you need.
Hope I could help you