63 036
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #3688 in C# for yashveer singh

Question #3688
How do we make forms size, location and fit into main form
at the fixed position?
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions