c# - How to make a button that changes apperance on mouseover event? -


i creating windows forms application in visual studio 2010. need make button has different image changes on mouseover , mousedown events.

i used this:

public form1()       {            initializecomponent();            button1.mouseenter += new eventhandler(button1_mouseenter);            button1.mouseleave += new eventhandler(button1_mouseleave);       }        void button1_mouseleave(object sender, eventargs e)       {            this.button1.backgroundimage = ((system.drawing.image)(properties.resources.img1));       }         void button1_mouseenter(object sender, eventargs e)       {            this.button1.backgroundimage = ((system.drawing.image)(properties.resources.img2));       } 

i saved images in resources "img1" , "img2". however, not recognised.

this.button1.backgroundimage = ((system.drawing.image)(properties.resources.img2));

what put instead of "img2" in example ? how access image resources? button has bevel-border. how remove it?

hope made myself clear , understand problem... vlad

looks resources.resx file located under properties folder. go project root folder , expand "properties" folder , should see "resources.resx" file. double click on , should open screen list of resources.

first menu item in new screen allows see resources type. select "images" , should see have attached resources. can add more resources it.

attaching file project doesnt mean added resources, have manually add using above screen can use:

properties.resources.img2 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -