C# make background image fit the screen?

14,186

Solution 1

Just set the forms BackgroundImageLayout to Stretch.

This will probably cause flickering, to prevent this you can (in the ctor):

this.SetStyle(
    ControlStyles.AllPaintingInWmPaint |
    ControlStyles.DoubleBuffer,
    true);

Solution 2

Set the BackgroundImageLayout() property of the Form to either "Stretch" or "Zoom".

Share:
14,186
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I decided to add a background image to my winforms application and I wonder how I can make the background always fit with the screen? (auto-stretch it).

    I have a form where users can resize it and choose their own window size, but I want the background to always fill the application. I have a huge background wallpaper, about 2000x1500 in resolution, if the user resize the form window to about 500x500 it will only show a small part of the wallpaper, how can I make it show the full wallpaper but in a smaller resolution?

    I haven't found anything about this and I have no idea where to even start. Could anyone help me?