• Top Members
    Reps
    Posts
  • 834 Replies
    2585 Replies
  • 716 Replies
    2026 Replies
  • 331 Replies
    1928 Replies

★ VB.NET Custom Buttons | 2 ways ★

User avatar
CleverBoy
VIP - Donator
Posts: 395

★ VB.NET Custom Buttons | 2 ways ★

Tue Mar 08, 2011 10:38 pm

Hello Coders, In this tutorial i will show you how to make a custom button in Visual Basic 2008 / 2010

The First Way

≫Open VB and start new windows form application
≫Create New UserControl name it anything you want and then Change these properties :

Size : To what you want
MinimumSize : The Same as the Size exactly
MaximumSize : The Same as the Size exactly
BorderStyle : Fixed Single


≫And add a button and set it properties to :

Name to : Btn
Text : To the custom button name or anything you want
BorderStyle : Flat
Change Modifiers to : Friends

≫And now change the button theme you can change the colors of : Back + Fore or Add A background image..
when you done Debug it and see in your ToolBox you will found the button at the top add it to your form and then you can add codes like this Example :

Code: Select all

<CUSTOMBUTTON>.btn.text = "Button1"
Custombutton.btn.forecolor = color.black
Finish !

The Second way

Its too easy just
≫Add a button and change it background image to what you want then add 3 images to your resources

1 Button up
1 Button down
1 Button Hover

≫On Button1_MouseUp

Code: Select all

Button1.BackgroundImage = My.Resources.<MouseUpImage>
≫On Button1_MouseDown

Code: Select all

Button1.BackgroundImage = My.Resources.<MouseDownImage>
≫On Button1_MouseHover

Code: Select all

Button1.BackgroundImage = My.Resources.<MouseHoverImage>
Finish !

Hope you learn something from this simple tutorial please don't forget
Comment, Rate, +Rep if you like it!
Last edited by CleverBoy on Tue Mar 08, 2011 10:48 pm, edited 1 time in total.

User avatar
Codex
Coding God
Posts: 2026

Re: ★ VB.NET Custom | Buttons 2 ways ★

Tue Mar 08, 2011 10:40 pm

For n00bs, this is a great tutorial, for me, i already know this. but you will get +rep for making a tutorial :D
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender

User avatar
CleverBoy
VIP - Donator
Posts: 395

Re: ★ VB.NET Custom | Buttons 2 ways ★

Tue Mar 08, 2011 10:45 pm

CodexVideos wrote:For n00bs, this is a great tutorial, for me, i already know this. but you will get +rep for making a tutorial :D
I was just free so i think to make a tutorial + my pc is crashed and im using mac for this resone no screans + lol did you notice that the title like ? Nery tutorial lol ! 8-)

User avatar
zulfikar
Member
Posts: 30

Re: ★ VB.NET Custom Buttons | 2 ways ★

Mon Aug 22, 2011 9:23 pm

for the code

Code: Select all

<CUSTOMBUTTON>.btn.text = "Button1"
Custombutton.btn.forecolor = color.black
How exactly do you input it and where. What is CUSTOMBUTTON changed to? if it changed? if these questions could be answered, it would be of great help
Image

User avatar
CleverBoy
VIP - Donator
Posts: 395

Re: ★ VB.NET Custom Buttons | 2 ways ★

Mon Aug 22, 2011 10:01 pm

OK then you need private tutorial :P


This is the First Way

Look CUSTOMBUTTON isn't right you should rename it with the Button name you choosed for this.

So lets start from beginning:

First: Create new VB Project or Use the one u working on it
Second: Create new UserControl and name it zButton (Just example)
Third: Change the UserControl (zButton) properties so:

the Size should be like what u want
then Copy the 'size' and paste it in "Maximum Size" and "Minimum Size"

then change BorderStyle to Fixed Single or Any1 u want
ok

Now!

Add a button to the UserControl
Name it "Btn"
and change Dock to "Fill"
and text to "zButton" or anything u want
and FlatStyle to Flat
IMPORTANT!!! to :change modifiers to "Friends"

then now you can change the Button Colors or Add Image to it or anything u want to do to change the button to make it custom
when u finish debug your program and stop debuging then you will see in ur Toolbox the Usercontrol add it to ur form

then... you can't edit the button but u can by codes like:

Code: Select all

zButton1.btn.text = "CodenStuff" 'or anything :D
important to do zButton1.BTN!!!... anything

----
xD this is my explanation if u understand cooll; if not not my problem dunnno; :P

... but i tthink the second way is better lmao;

:roll: :!: puko; im tired from typing ...

Thanks

+rep +donate if you want +rate 5 :P

User avatar
zulfikar
Member
Posts: 30

Re: ★ VB.NET Custom Buttons | 2 ways ★

Mon Aug 22, 2011 10:47 pm

+rep to you. For the customizing i get it now, but instead of colour.black would it possible to use HTML colours ( ARGB value )

or any charts that acually show what the colour looks like? for example : firebrick


NVM i see the chart or list at the properties lol im so forgetful at time omg; well thanks for your tut cooll; cooll; cooll; wahooo;
Image

User avatar
M1z23R
VIP - Donator
Posts: 622

Re: ★ VB.NET Custom Buttons | 2 ways ★

Mon Aug 22, 2011 11:11 pm

There are 3 ways, one is inheriting UserControl and simply adding button on it, second one is inheriting Button it self and messing with it's events, and third one is inheriting Control and making it from scratch !

User avatar
CleverBoy
VIP - Donator
Posts: 395

Re: ★ VB.NET Custom Buttons | 2 ways ★

Tue Aug 23, 2011 1:43 am

Thanks mate i had fun helping newbie :P

Post Reply

Return to “Tutorials”