Results 1 to 5 of 5

Thread: Button Design Help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Button Design Help

    Hi Everyone,

    I am needing some help in the design of buttons within my application. Below is what I am trying to do with in my buttons.

    Default button image
    Mouse over button image
    Mouse down button image
    No border surrounding buttons

    I am trying to have a button (with no border) that has a default image within it. When a mouse goes over the button I would like a second image to appear. Then when the button is clicked, I would like the third image appear.

    How do I call the images for mouse over and click options? Also, how do I make my buttons not have a border around them?

    Thank you all in advance!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Button Design Help

    Set the FlatStyle to Flat and the FlatAppearance.BorderSize to zero.

    Handle the MouseEnter, MouseDown, MouseUp and MouseLeave events and set the appropriate BackgroundImage in each event handler. I'd suggest inheriting the Button class and adding properties for each of the extra images.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Re: Button Design Help

    Hi jmcilhinney,

    The border suggestion worked perfectly! Thanks!

    I'd suggest inheriting the Button class and adding properties for each of the extra images.
    Can you give me a quick example of this? I have never seen this before.

    Thank you for your help.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Button Design Help

    Quote Originally Posted by Giraffe Frenzy
    Can you give me a quick example of this? I have never seen this before.
    Yes you have because you do it all the time. Every time you design a form you are inheriting the Form class and adding your own members. In this case it would look something like:
    VB Code:
    1. Public Class ButtonEx
    2.     Inherits System.Windows.Forms.Button
    3.  
    4.     Private _standardImage As Image
    5.  
    6.     Public Property StandardImage() As Image
    7.         Get
    8.             Return Me._standardImage
    9.         End Get
    10.         Set
    11.             Me._standardImage = value
    12.         End Set
    13.     End Property
    14.  
    15.     Protected Overrides Sub OnLeave(ByVal e As EventArgs)
    16.         MyBase.OnLeave(e)
    17.         Me.BackgroundImage = Me._standardimage
    18.     End Sub
    19.  
    20. End Class
    You'd add corresponding code for the other two images and the Enter, MouseDown and MouseUp events.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: Button Design Help

    If the solution 'worked perfectly' then you don't and really shouldn't add extra code, it just makes your application slower.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width