Add icon on button to beautify the look of button in vb.net.
How To
1. Import resource , we need image with resolution 64px x 64px and extention (PNG / ICO) because it support transparent.
to import:
* Project > Properties > select RESOURCE > Add Resource > Add Existing File and select the image.
2. After success import , we change the property the button. find property "Text Image Relation" and set "Image Before Text"
3. now setup the image size on the button, we need event form_load to do this, look code below :
'---- start here----
Dim btnImageIco As New Bitmap(New Bitmap(My.Resources.myimage), 16, 16)
commandButton1.Image = btnImageIco
commandButton1.ImageAlign = ContentAlignment.MiddleCenter
'---- end ------
explanation :
* 16 , 16 => size image in pixel , you can change it
* ContentAlignment.MiddleCenter => image and text is center with relation "Image Before Text" look step 2
if you have trouble with align you can make change with just lengthen the size of button.
Post a Comment
Harap gunakan bahasa yang baik dan sopan, terima kasih