I need to change the background image of my form when i klick a button, and change it back to null again the second time it is clicked, how can i do this?
To change the background color, select the form in Visual Studio and locate the BackColor property in the Properties panel. There are a number of ways to specify a color. Color by name - Simply type in a color name into the BackColor value field (for example Red, Yellow, Cyan etc).
Set the background in the Windows Forms DesignerSelect the Custom tab to display a palette of colors. Select the Web or System tab to display a list of predefined names for colors, and then select a color.
Use BackgroundImage property:
form.BackgroundImage = image;
to hide the image:
form.BackgroundImage = null;
Put this source code to ClickButton method:
form.BackgroundImage = form.BackgroundImage == null ? image : null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With