0

I created a .NET Framework 4.0 winforms project and added a "tab" as you can see in the following picture:

enter image description here

From the View Designer both tabs (Profile and Features) looks like they fit the rectangle window, but when I run the program, the "Profile" tab looks the same but the "Features" tab suddenly does not fit the rectangle anymore and looks like that:

enter image description here

I don't want to give the user the option to enlarge the window.

I am wondering why it looks like it fit the rectangle window but when I run the application, it does not.

This is the "Features" tab from the MainForm:

        this.TabPage2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
        this.TabPage2.Controls.Add(this.listBoxShowFriendsBirthday);
        this.TabPage2.Controls.Add(this.buttonShowFriendsBirthday);
        this.TabPage2.Controls.Add(this.label1);
        this.TabPage2.Controls.Add(this.monthCalendar1);
        this.TabPage2.Controls.Add(this.postTextBox);
        this.TabPage2.Controls.Add(this.pictureBoxEvent);
        this.TabPage2.Controls.Add(this.listBoxFetchEvents);
        this.TabPage2.Controls.Add(this.buttonFetchEvents);
        this.TabPage2.Controls.Add(this.postButton);
        this.TabPage2.Location = new System.Drawing.Point(8, 39);
        this.TabPage2.Name = "tabPage2";
        this.TabPage2.Padding = new System.Windows.Forms.Padding(3);
        this.TabPage2.Size = new System.Drawing.Size(1976, 806);
        this.TabPage2.TabIndex = 1;
        this.TabPage2.Text = "Features";
        this.TabPage2.UseVisualStyleBackColor = true; 
Lennart
  • 9,657
  • 16
  • 68
  • 84
jrz
  • 1,213
  • 4
  • 20
  • 54
  • Is your application DPI-Aware? I assume it's not. Read here: [How to configure an app to run correctly on a machine with a high DPI setting](https://stackoverflow.com/questions/13228185/how-to-configure-an-app-to-run-correctly-on-a-machine-with-a-high-dpi-setting-e?answertab=active#tab-top). [Some notes I've written:](https://stackoverflow.com/questions/50239138/dpi-awareness-unaware-in-one-release-system-aware-in-the-other?answertab=active#tab-top) (these are being updated). – Jimi Nov 22 '18 at 13:34

2 Answers2

0

I suggest you to use Dock and Anchor properties of controls. This way you can also allow to user resizing the window.

Dock:

enter image description here

Anchor:

enter image description here

See - How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control

kgzdev
  • 2,770
  • 2
  • 18
  • 35
0

To prevent the user from rescaling their window: c# how to prevent user from resizing my application window?

but aside from that, I'd suggest, (just like ikram said) to use docking, that way you're certain your lay-out will remain, no matter the resolution/screensize the user has.