I want to centre a popup form launched using Form.ShowDialog() in .NET Compact Framework. I dont see any property like StartPosition in .NET CF Form object.
Can someone please suggest me how to centre popups in .NET CF 3.5?
You can make an extension method that does the work for you:
public static class FormExtensions
{
public static void CenterForm(this Form theForm)
{
theForm.Location = new Point(
Screen.PrimaryScreen.WorkingArea.Width / 2 - theForm.Width / 2,
Screen.PrimaryScreen.WorkingArea.Height / 2 - theForm.Height / 2);
}
}
You call it like this:
TheDialogForm f = new TheDialogForm();
f.CenterForm();
f.ShowDialog();