Alper
Alper

Reputation: 1

How do I get controls to resize properly using C#?

So I've created a new C# Windows Form, I'm using the Gecko Web Browser control and I want the browser to resize with the rest of my program (stretching or shrinking) as opposed to the "white space" of the program (the navigation bar, etc.) to resize. How might I cause the control to resize with the rest of the program?

Upvotes: 1

Views: 1101

Answers (2)

Stephen McDaniel
Stephen McDaniel

Reputation: 2968

If you just want the control to grow proportionally to it's original size (as opposed to DockStyle.Fill which will take up the entire area), you can use the Anchor property. If you set the web browser control to be anchored Top, Left, Bottom and Right, then it will grow and shrink as the form is resized. It's probably easiest to set it from the Visual Designer but if you want to do it via code you can use:

geckoWebBrowser.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

Upvotes: 1

c0deNinja
c0deNinja

Reputation: 3986

in the control's property set the dock to fill

geckoWebBrowser.Dock = DockStyle.Fill;

Upvotes: 0

Related Questions