Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximize a window programmatically and prevent the user from changing the windows state

Tags:

c#

.net-2.0

How do I maximize a window programmatically so that it cannot be resized once it reaches the maximized state (for example, maximize Internet Explorer and see it)?

I set FormWindowState property as

this.WindowState = FormWindowState.Maximized;
this.MaximizedBounds = (x,y);

but it doesn't work. How do I do this?

The window I want to maximize is a window in my application.

like image 814
karthik Avatar asked Aug 17 '10 09:08

karthik


2 Answers

When your form is maximized, set its minimum size = max size, so user cannot resize it.

    this.WindowState = FormWindowState.Maximized;
    this.MinimumSize = this.Size;
    this.MaximumSize = this.Size;
like image 168
Ram Avatar answered Sep 22 '22 06:09

Ram


You were close... after your code of

WindowState = FormWindowState.Maximized;

THEN, set the form's min/max size capacity to the value once its sized out.

MinimumSize = this.Size;
MaximumSize = this.Size;
like image 35
DRapp Avatar answered Sep 19 '22 06:09

DRapp