HostGator promo code
Get cash from your website. Sign up as affiliate

Aug 10, 2011

make custom button in vb.net or c#.net


Hi friends to day i am going to tell you about how to make custom button in vb (visual basic).net or c#.net
pleas follow my instructions:

note:
    you want to make 3 png images for the button, so pleas see the video below....

1)Create an form in VB or c#.
2)import a button in to that form.
3)click on "project" and go to bottom . there will be your project properties

ex:
   if u r project name= "button project".
  click on "project" and go to bottom . there will "button project properties.."
  
4)click that and go to "Resources".
5)click the arrow the is near to "Add Resources".
6)click "add existing file".
7)search for your images that you are created for your "custom button".
8)add those three images in to resources.
9)click on your project and click on your button.
10)under the button properties change the values that i am given hear:
        
            Flat Style = Flat

11) maximize "Flat Appearance" that is on top of "Flat Style" and change the values that i am given hear:
            
              Border Size = 0
              MouceDownBackColor = Transparent 
              MouceOverBackColor = Transparent
             
12) go to "Back color" that is in top. change the values that i am given hear:
         
             BackColor = Transparent

13) change the image of the button by clicking "BackgroundImage".

(click the "BackgroundImage" after that your radio button should be click in "Project Resources File" under that you can see your images that you assigned)

14)click on the Button again and add some "MouseDown Events",the icon is look like "yellow color lightning"(search the existing event and double click it  ). add these events:
         
  • MouseDown
  • MouseEnter
  • MouseLeave
  • MouseUp
After adding Events finalized code look like this ( Pleas copy and the code to exact event):

        private void button4_MouseDown(object sender, MouseEventArgs e)
        {
            button4.BackgroundImage = Properties.Resources.add_click;
        }

        private void button4_MouseEnter(object sender, EventArgs e)
        {
            button4.BackgroundImage = Properties.Resources.add_hower;
        }

        private void button4_MouseLeave(object sender, EventArgs e)
        {
            button4.BackgroundImage = Properties.Resources.add;
        }

        private void button4_MouseUp(object sender, MouseEventArgs e)
        {
            button4.BackgroundImage = Properties.Resources.add_hower;
        }

15) run the program and move your mouse to button, click it and leave it

You will see the Answer and ENJOY!!!!!

For VB.net users follow the same instructions and in 14 your code like this:

        private void button4_MouseDown(object sender, MouseEventArgs e)
        {
            button4.BackgroundImage = My.Resources.add_click;
        }

        private void button4_MouseEnter(object sender, EventArgs e)
        {
            button4.BackgroundImage = My.Resources.add_hower;
        }

        private void button4_MouseLeave(object sender, EventArgs e)
        {
            button4.BackgroundImage = My.Resources.add;
        }

        private void button4_MouseUp(object sender, MouseEventArgs e)
        {
            button4.BackgroundImage = My.Resources.add_hower;
        }


ENJOY!!!!!


for more reference pleas see the video.



this is in VB.net. for c#.net  change "My"to "Properties"

No comments:

Post a Comment