Tuesday, February 17, 2015
How to Create Custom Button in VB Net
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.
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.
Also Read: Lab Login System Mini Project in VB.Net
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.

- Click Here to Download Full Project -
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment