I have made a GUI app (WIN FORM) which is running fine on 12 inch screen(no cropping of the form) but on other Laptops having screen > 12 inches Win Form is going beyond the taskbar and some portion of the Form is not visible to the user.I have fixed it currently by squeezing certain UI boxes on the Form .But why this is happening?How can I auto-rectify it for all the PC models.
Asked
Active
Viewed 578 times
0
-
Do you only want to strech your form to maximum? – Slashy Aug 24 '15 at 09:57
-
If you want to resize all controls and form then that is quite hard to achieve, [see this for c#](http://stackoverflow.com/questions/8523392/how-can-i-re-size-controls-based-on-resolution) and [this is for vb.net](http://stackoverflow.com/questions/23259261/automatically-adjusting-winform-and-controls-to-screen-size) which will give you an idea how to achieve your objective, if your only problem is to resize form, use autosize and autoscroll properties. – Kryptonian Aug 24 '15 at 10:00
-
Whats the reason behind its cropping or overshooting beyond the task bar?is it the resolution?or some other setting? – Raulp Aug 24 '15 at 11:09
2 Answers
0
You may want to have a look at Form.AutoSize property. Also, in the link, look at AutoSizeMode.
However, to be able to fix this you may need to rewrite the whole form.

Nevca
- 194
- 1
- 1
- 9
0
It sounds like a fixed sized dialog (at least I suppose it wouldn't be a problem with a resizable form).
You should adjust your form height to the desktop size (and maybe width too). The code below will shrink the form if it is too large and displays the scrollbar to make possible to access the remaining area.
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
AdjustHeight();
}
private void AdjustHeight()
{
Rectangle screen = Screen.FromControl(this).WorkingArea;
int screenHeight = screen.Height;
if (screenHeight < Height)
{
Height = screenHeight;
AdjustFormScrollbars(true); // not needed if AutoScroll property is true
}
}

György Kőszeg
- 17,093
- 6
- 37
- 65