I have made my own control inherited from System.Windows.Forms.UserControl
then by using reflection I have created an object from my own control at run time
after creation this control have been added to the collection of the container(form)
System.Windows.Forms.Form.Controls.
the problem is
how to handel this control's events as (MouseDown , MouseUp , DragDrop , DragEnter and DragOver)??
AlanPosted Aug 24, 2008, 5:40 PM
Well, you will need to add the eventhandlers to your form at compile time. For example:
private void myUserControl_MouseDown(object sender, MouseEventArgs e)
{
// code
}
but you'll need to wire up these eventhandlers at run time.
So, if myUserControl denotes a reference to the user control you've created using reflection and added to the form's Controls collection:
myUserControl.MouseDown += myUserControl_MouseDown;
You will, of course, need to add all this code to the form manually as the VS designer won't have any knowledge of the user control to be added.