简体   繁体   中英

Background image not resizing - C#

I set BackgroundImageLayout to Stretch , but the background image is not resizing correctly.

Here's what my form originally looks like: 在此处输入图片说明

And here's what happens when I resize it: 在此处输入图片说明

Why does this happen and how can I fix it?

EDIT: 1 - I'm using WinForms;

2 - It's the background image of a Form.

3 - Here a photo of my project's properties:

在此处输入图片说明

Okay, a simple fix would be to add this to the forms Resize event, like this:

private void Form1_Resize(object sender, EventArgs e)
{
    this.Refresh();
}

On a side note, unfortunately, for reasons I don't understand, this should fix it, but in my testing it did not:

this.ResizeRedraw = true;

It looks like a bug in the MDI forms implementation to me. The background image also would not show up properly in design mode on my system when the form "IsMdiContainer" is set to true.

It should work if the background image is set as shown below.

whatever.BackgroundImageLayout = ImageLayout.Stretch

Can you put a photo of your property settings?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM