How do we make forms size, location and fit into main form
at the fixed position?
public MainForm()
{
InitializeComponent();
// this is the
default
this.WindowState = FormWindowState.Normal;
this.StartPosition =
FormStartPosition.WindowsDefaultBounds;
// check if the saved bounds are
nonzero and visible on any screen
if (Settings.Default.WindowPosition !=
Rectangle.Empty
&&
IsVisibleOnAnyScreen(Settings.Default.WindowPosition))
{
//
first set the bounds
this.StartPosition =
FormStartPosition.Manual;
this.DesktopBounds =
Settings.Default.WindowPosition;
// afterwards set the window state to
the saved value (which could be Maximized)
this.WindowState =
Settings.Default.WindowState;
}
else
{
// this resets the upper left
corner of the window to windows standards
this.StartPosition =
FormStartPosition.WindowsDefaultLocation;
// we can still apply the saved
size
this.Size = Settings.Default.WindowPosition.Size;
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C#