Based on my research, the only way to get a MessageBox Form to Center on the parent form is to write a custom MessageBox class. I have successfully implemented the CustomMessageBox Form and am able to center my errors and informational messages on the parent form. However, I cannot figure out how to make the CustomMessageBox form static so that I do not have to instantiate my new CustomMessageBox Form. I want to be able to just call a static method like below:
CustomMessageBox.Show(type, message, etc...)
The basic version of my MessageBox class is below. Ideally, I would like to have the functionality to display this form without having to instantiate my CustomMessageForm. Is this possible?
namespace MarineService
{
public partial class CustomMessageForm : DevExpress.XtraEditors.XtraForm
{
private static CustomMessageForm form = new CustomMessageForm();
public CustomMessageForm()
{
InitializeComponent();
}
public void ShowDialog(string type, string message)
{
this.Text = type + "Information";
this.groupMessage.Text = type + "Information";
this.memoEditMessage.Lines[0] = message;
}
}
}