I am making a MessageBox like class (MessageBoxCustom).
I would like to have a Form with designer support in a separate file so I can modify the appearance through Visual Studio (MessageBoxCustomDialog ).
I would also like to make this MessageBoxCustomDialog unreachable by code outside MyMessageBox and I’m nesting MessageBoxCustomDialog. I would like to move it in a separate file so I’d have designer support. Maybe using a partial class? How would the hierarchy go?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace System.Windows.Forms
{
public static class MessageBoxCustom
{
public static void Show()
{
(new MessageBoxCustomDialog()).ShowDialog();
}
private class MessageBoxCustomDialog : Form
{
}
}
}
The Visual Studio Designer can not help you design nested classes. It is just not made for that. It checks the type of the first outermost class in the file and then decides which designer to use.
If it is just about designing the layout of the form I would recommend to design it as usual. When you finished your project you can then surround the class by the outer class (in both files) and make it private.
When you finshed your work just copy and paste the dialog class into the outer class and make it private. If you have to rework the design it is again just copy and paste.
MessageBoxCustomDialog.cs:
MessageBoxCustomDialog.Designer.cs: