|
-
Apr 21st, 2007, 10:42 AM
#1
Thread Starter
Addicted Member
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!
-
Apr 21st, 2007, 11:08 AM
#2
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.
-
Apr 21st, 2007, 11:16 AM
#3
Thread Starter
Addicted Member
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.
-
Apr 21st, 2007, 11:26 AM
#4
Re: Button Design Help
 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:
Public Class ButtonEx
Inherits System.Windows.Forms.Button
Private _standardImage As Image
Public Property StandardImage() As Image
Get
Return Me._standardImage
End Get
Set
Me._standardImage = value
End Set
End Property
Protected Overrides Sub OnLeave(ByVal e As EventArgs)
MyBase.OnLeave(e)
Me.BackgroundImage = Me._standardimage
End Sub
End Class
You'd add corresponding code for the other two images and the Enter, MouseDown and MouseUp events.
-
Apr 21st, 2007, 11:27 AM
#5
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|