1

Currently I am working on a little winforms application. But I have issues with the from size. I set a size at the designer and I also checked in the initialize component if the size is correct and it is. But when I run the program the size is smaller than in the designer. Here some screenshots:

In the designer:

At run time: enter image description here

My code at initialize component method:

    this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(800, 1092);
    this.Controls.Add(this.addressTextBox);
    this.Controls.Add(this.addressLabel);
    this.Controls.Add(this.descriptionRichTextBox);
    this.Controls.Add(this.homepageTextBox);
    this.Controls.Add(this.endDateTextBox);
    this.Controls.Add(this.startDateTextBox);
    this.Controls.Add(this.locationTextBox);
    this.Controls.Add(this.homepageLabel);
    this.Controls.Add(this.endDateLabel);
    this.Controls.Add(this.startDateLabel);
    this.Controls.Add(this.locationLabel);
    this.Controls.Add(this.descriptionLabel);
    this.Controls.Add(this.nameTextBox);
    this.Controls.Add(this.nameLabel);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
    this.MaximizeBox = false;
    this.Name = "EventDetailsWindow";
    this.Text = "ParkManager - Veranstaltung";
    this.ResumeLayout(false);
    this.PerformLayout();
Thomas5897
  • 61
  • 2
  • 9
  • 1
    https://stackoverflow.com/questions/13228185/how-to-configure-an-app-to-run-correctly-on-a-machine-with-a-high-dpi-setting-e – Hans Passant May 06 '18 at 16:05
  • `this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;` change to `None`. – Zohar Peled May 06 '18 at 16:06
  • @ZoharPeled Tried but than it looks much worse – Thomas5897 May 06 '18 at 16:07
  • There are so many things that can change the size of WinForms that this box is not large enough to list them all. There are good reasons for each of these things and you would be best to let them do their work; stop trying to make runtime output look exactly as it does on your development machine as that will almost certainly make it unusable for everyone else. – Dour High Arch May 06 '18 at 16:27
  • Then go with Hans Passant's link – Zohar Peled May 06 '18 at 17:52

0 Answers0