>I have some code in a custom contol that is trying to run code in the form that the control is placed on. I want the code to be written in the control so I don't have to duplicate it for each contol I place on the form (I hear that's good programming practice :).
>
>Here's the code:
>
>MainWin1 = (MainWindow)this.TopLevelControl;
>MainWin1.MainMenu(MainWindow.MenuName.search);
>
>Application.Run(mainwin); - This turns NULL for some reason.
>
I don't really do much Winforms development so YMMV, but I've been under the impression Application.Run() was meant to kick off the message event loop and you did this only once when your app. starts. All other forms are just displayed with:
Form form1 = new NameOfForm();
form.Show();