Have you ever thought of changing the look of your Buttons in Visual
Basic? Then you are at right place, I’ll be showing you how you can
make your own custom button controls in visual basic.
Basic? Then you are at right place, I’ll be showing you how you can
make your own custom button controls in visual basic.
Note: If you know how to design buttons in photoshop or whatever you use then
you can specifically design your own buttons and if you don’t know then not a
big deal you can download our custom buttons over here: Download Custom Button Project Resource Files.
you can specifically design your own buttons and if you don’t know then not a
big deal you can download our custom buttons over here: Download Custom Button Project Resource Files.
Also Read: Lab Login System Mini Project in VB.Net
How to Create Custom Button in VB.Net
- Let’s get started by creating a new windows form application in visual basic.
- Go to solution explorer – Under your Project select My Project – Resources.
- Select Add Resource – Add Existing File, and browse the downloaded images.
- Now go to Project in MenuBar and select Add Class and name you class like TheCrazyProgrammerButton, BradleyButton, MissionButton or something like that.
- Remove all the existing code in the class and paste the below code.
Public Class TheCrazyProgrammersBtn Inherits Windows.Forms.Button Public Sub New() 'Making Existing Button Transparent Me.FlatStyle = Windows.Forms.FlatStyle.Flat Me.FlatAppearance.BorderSize = 0 Me.FlatAppearance.MouseDownBackColor = Color.Transparent Me.FlatAppearance.MouseOverBackColor = Color.Transparent Me.BackColor = Color.Transparent 'ReDevelop the existing Button adding image to a transparent image Me.BackgroundImage = My.Resources._1button Me.BackgroundImageLayout = ImageLayout.Stretch End Sub Private Sub TheCrazyProgrammersBtn_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown Me.BackgroundImage = My.Resources._1button_click End Sub Private Sub TheCrazyProgrammersBtn_MouseHover(sender As Object, e As EventArgs) Handles Me.MouseHover Me.BackgroundImage = My.Resources._1button_hover End Sub Private Sub TheCrazyProgrammersBtn_MouseLeave(sender As Object, e As EventArgs) Handles Me.MouseLeave Me.BackgroundImage = My.Resources._1button End Sub Private Sub TheCrazyProgrammersBtn_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp Me.BackgroundImage = My.Resources._1button End Sub End Class
- Now run your Projects once close it. After that you can see a new control named “YourClassName” in your ToolBox.
- Drag it on you windows form and you are ready to use your custom button.
That was a wonderful one! Am a newbie in vb.net programming and am wowed by this!
Is the downloadable costume button resource available for win8?
Help. I got errors :
btn_hover is not a member of ‘Resource’
btn_up is not a member of ‘Resource’
btn_down is not a member of ‘Resource’
I used my own images. By the way, the zip file you have linked in this page seems to be corrupted.
Having issues with crashing during calling MouseEventArgs MouseHover and MouseLeaves. All works well but it crashes my program when this is called. I retyped the code myself and it compiled ok, If i comment out the subs for the events the program does not crash. Button performs as a normal button should.
Any ideas?
This is fantastic. I love the direct way this creates buttons that look good.
Many Thanks
This is a button that you’ve created.
I would like to know how I can convert a png image I have into a button.
Further the button should change color smoothly when I hover my mouse over it.
How do I do stuff like that ?
Thank you