I've always been a bit annoyed by the over 200 methods and properties that
are inherited from Form, so I came up with a technique to get around this. I
create the Form in the designer, and then I wrap the Form class in an outer
class that acts as my dialog. This lets me keep the interface limited to the
the properties and methods that pertain directly to my dialog. I'm about to
implement this, but I'm afraid of any potential negative side effects. One
thing that worries me, is will the nested form plug into the message loop
correctly. So far the code runs ok, but I'm afraid of an unsuspecting side
effect nailing me at a critical time, i.e. during a demo. Here's an example
of what I'm doing.
public class ActionDialog:IDisposable
{
private ActionForm _form = new ActionForm();
//ActionDialog Definition....
public DialogResult ShowDialog(IWin32Window owner)
{
//Setup Form...
return _form.ShowDialog(owner);
}
public void Dispose()
{
_form.Dispose();
}
private class ActionForm : Form
{
//ActionForm definition....
}
}