vb.net - Button images, transparency, MouseOver colors -
i have button have made flat, no border when there image in it, seamless looking.
the image want add button unfilled rectangle (png file).
when mouse on button, have backcolor change red. when does, rectangle image not change red..it stays whatever color image.
i wanted know if there way add image, who's actual backcolor transparent (i suppose?).
the image blue rectangle very light brown background. when mouse on entire button's backcolor red, maintain blue rectangle. right when mouseover can see size of image itself.
i'd rather not draw graphics button. (in actuality image outline of computer monitor...but it's rectangle case)
is there way image or backgroundimage properties?
put image in resources
(project/properties/resources/images/add resource , dropdown menu choose add existing file...).
then use code :
private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load button1 .text = "" .usevisualstylebackcolor = false .backcolor = color.transparent .flatstyle = flatstyle.flat .flatappearance.bordersize = 0 .flatappearance.mouseoverbackcolor = color.red .backgroundimagelayout = imagelayout.center .backgroundimage = my.resources.xxx 'image name resources end end sub private sub button1_mousehover(byval sender object, byval e system.eventargs) handles button1.mousehover button1 .backgroundimage = nothing .flatappearance.bordercolor = color.blue .flatappearance.bordersize = 2 'or size of border in px (take image) end end sub private sub button1_mouseleave(byval sender object, byval e system.eventargs) handles button1.mouseleave button1 .backcolor = color.transparent .backgroundimage = my.resources.xxx 'image name resources .flatappearance.bordersize = 0 end end sub
of course, can create own button (class) , import project, can avoid mousehover
, mouseleave
every button.
btw. can without image if picture have border
, background
of image isn't gradient. can avoid mousehover
, mouseleave
.
edit : there code if don't need image (border of button blue
of 2px
, background color kind of light brown, , on hover background color red border stay blue 2px).
with button2 .usevisualstylebackcolor = false .backcolor = color.fromargb(217, 195, 154) .flatstyle = flatstyle.flat .flatappearance.bordersize = 2 .flatappearance.bordercolor = color.blue .flatappearance.mouseoverbackcolor = color.red end
Comments
Post a Comment