.NET 2003 Background Image on form
Hey guys,
I wanted to have an image as the background of my form. My form will always be maximised.
I have declared my image as a bitmap but when i say
Me.BackgroundImage = imgBackground
the image displays tiled and i want it to stretch to the full size of the form.
I have tried to change the width, height and size of the image but it gives me an error saying that they are read only.
Is there anyway i can get the image to fill the form?
Thanks in advance for any help.
:afrog:
Re: .NET 2003 Background Image on form
Code:
MyBase.BackgroundImageLayout = ImageLayout.Stretch
put that in your form load or where you load the image.
Re: .NET 2003 Background Image on form
Hey, Thanks for the reply, but now i get an error message saying that 'BackgroundImageLayout' is not a member of 'System.Windows.Forms.Form'.
Is there something else i need to include in my code before i can use this?
Re: .NET 2003 Background Image on form
The BackgroundImageLayout property was new in .NET 2.0.
You do need to change the size of your image but you cannot resize an existing Image object. You need to create a new Bitmap of the desired size, create a Graphics object for it and use that to draw the original Image onto the new one.