Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change background image of a form in c#?

Can I use Menu strip or context menu to allow the user so that he can change the background image of the window instead of background colour in c# ?

like image 377
user3004295 Avatar asked Nov 18 '13 10:11

user3004295


People also ask

How do I change the background in Windows form?

Set the background in the Windows Forms Designer Select 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. In the Properties window, click the arrow button next to the BackgroundImage property.


1 Answers

You can use MenuStrip Control to change the BackgroundImage of the Form.

Note: Here i'm giving you the steps/idea so that you can change as per your requirements.but you need to Explore more.

Steps:

1.You add the MenuStrip control from Menus & Toolbars Category in ToolBox and then Add the MenuStrip To the Form.

2.You can add Menu Items as you want .ex: change Image1,change Image2 etc.,

3.You can handle the MenuItemClick Event to Change the BackgroundImage of the Form

Sample Code:

private void changeBGImageToolStripMenuItem_Click(object sender, System.EventArgs e)
{
    Image myimage = new Bitmap(@"D:\Images\myImage1.jpg");
    this.BackgroundImage = myimage;
}

Sample code2: accessing Images from Resources file.
Note: first you need to add the Images into Resources.
Here i have added myImage1.jpg file to Resources.

See here for how to add images to Resources

this.BackgroundImage = Properties.Resources.myImage1;

Please let me know if you need anything more.

like image 71
Sudhakar Tillapudi Avatar answered Oct 18 '22 17:10

Sudhakar Tillapudi