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# ?
Asked
Active
Viewed 9.3k times
10
-
8Yeah, yes you can. – Ignacio Soler Garcia Nov 18 '13 at 10:41
-
@SoMoS How? can you please explain? – user3004295 Nov 18 '13 at 11:21
-
@dholakiyaankit I dont know how to do so..this is my first project..i need help – user3004295 Nov 18 '13 at 11:22
-
First of all add detailed explaination of your question then google it frist then try here this forum for http://stackoverflow.com/about – Just code Nov 18 '13 at 11:26
-
I am making an app for kids.. I want to give user the power of changing backgrounds according to the kid..if its a girl , parents can apply girly background images.. I want to add 5 background images for girls and 5 for boys , and i dont know how to do so – user3004295 Nov 18 '13 at 11:32
-
iam a student n iam learning c#, this is a small project my teacher gave so that we can learn.. i have googled it but didnt find anything – user3004295 Nov 18 '13 at 11:34
-
@user3004295: how is that a teacher gives a project without pointing out resources to learn how to do it? – Ignacio Soler Garcia Nov 18 '13 at 11:45
-
@SoMoS Iam not making any money, my project is almost ready.. my teacher said about changing the background colour, but i wana change background , thats it, if you know kindly help me.. i know how to add audio and images to resources, i know how to use audio, but i cnt figure out how to use image in context menu – user3004295 Nov 18 '13 at 11:47
-
teacher said to use our own ideas aswell.. n this is what i wana do, i do know about adding resources, making menus, teacher taught us .. – user3004295 Nov 18 '13 at 11:51
2 Answers
18
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.

Community
- 1
- 1

Sudhakar Tillapudi
- 25,935
- 5
- 37
- 67
-
awww it worked.. thank you so much :) , but it will work on my system only, can i add images to resources and use them from there? – user3004295 Nov 18 '13 at 12:16
-
You are welcome :) , yes you can access from resources, if you need i can edit my answer with "how to access images from resources" – Sudhakar Tillapudi Nov 18 '13 at 12:20
-
@user3004295: you can check my edited answer to know how to access images from Resources. – Sudhakar Tillapudi Nov 18 '13 at 12:39
-
@user3004295: you can check my edited answer i have already done it. – Sudhakar Tillapudi Nov 18 '13 at 12:45
-
First of all, thanks for this useful answer, but, is there any way to make the image as big as the window? In my case, the image is setted as background correctly, but it repeats – stack man May 19 '16 at 10:31
0
- every image you want use to background image form select in properties window again several once
- Go into soluitionExproler to child Form1 open Form1.Designer.cs
- copy this part of form Designer Form1.ActiveForm.BackgroundImage = global::TtimerComputer.Properties.Resources.ImageName;
- paste into your wanted change ImageName
Example:
private void btnBackSilver_Click(object sender, EventArgs e)
{
Form1.ActiveForm.BackgroundImage = global::YourProjectName.Properties.Resources.ImageName1;
}
private void btnBackGreen_Click(object sender, EventArgs e)
{
Form1.ActiveForm.BackgroundImage = global::YourProjectName.Properties.Resources.ImageName2;
}