Click here to Skip to main content
15,878,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can we remove a background image of a button? image need to be removed once the button is clicked.removing image means not replacing the existing image (not placing a new image on top of the previous). can we use "BackgroundImageChanged"?
can somebody give me a sample code if possible.
Posted

<big>button1.BackgroundImage = null;</big>
 
Share this answer
 
Comments
Member 7779792 16-Jun-11 9:49am    
thank you so much!!!
charles henington 20-Jun-11 18:15pm    
You are welcome, glad i could help:)
Just set the Buttons BackgroundImage property to Nothing in the Buttons Click event handler.
 
Share this answer
 
Just set the Image property to null: the image will disappear.
 
Share this answer
 
Comments
Member 7779792 16-Jun-11 9:49am    
thank you so much!!!
OriginalGriff 16-Jun-11 11:59am    
You're welcome.
button1.BackgroundImage = ""; 

(or)
button1.BackgroundImage = null;
 
Share this answer
 
Comments
charles henington 15-Jun-11 20:12pm    
button1.BackroungImage = ""; will thow error Error Cannot implicitly convert type 'string' to 'System.Drawing.Image'
Member 7779792 16-Jun-11 9:55am    
yes that's true!
button1.BackgroundImage =null;
is running properly.but not tha other one.
can we implement this same thing using,
BackgroundImage ="";
if so, what should be done to remove this above mentioned error?
charles henington 20-Jun-11 18:17pm    
Image img(string path)
{
if (Image.FromFile(path) != null)
{return Image.FromFile(path)}
return null;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900