Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi all. I am trying to make a custom button which is a label actually.
I have two issues. I cannot repaint when mouse enters control AND I cannot change the property of the PaintBackColor, HoverBackColor And BorderColor properties in the designer. Here is the code I currently have..
VB
Public Class PlayButton : Inherits Label
    Public Property PaintBackColor As Brush
    Public Property HoverBackColor As Brush
    Public Property BorderColor As Brush
    Public Property BorderSize As Single
    Protected Overrides Sub OnPaint(ByVal pevent As System.Windows.Forms.PaintEventArgs)
        TextAlign = ContentAlignment.MiddleCenter
        FlatStyle = Windows.Forms.FlatStyle.Flat
        BackColor = Color.Transparent
        AutoSize = False
        Dim OutPen As Pen = New Pen(BorderColor, BorderSize)
        pevent.Graphics.DrawEllipse(OutPen, 0, 0, Width, Height)
        pevent.Graphics.FillEllipse(PaintBackColor, 0, 0, Width, Height)
        MyBase.OnPaint(pevent)
    End Sub

    Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
    End Sub
End Class


Thank you in advance,
iProgramIt
Posted
Comments
Sergey Alexandrovich Kryukov 5-Mar-15 9:21am    
Hm... "...a custom button which is a label actually"? Why so, what is that supposed to mean?
What's the problem? Is that System.Windows.Forms? Please always tag it and provide some full names of some types, as
"Button" is ambiguous.
You do next to nothing in your code...
—SA
iProgramIt 5-Mar-15 18:27pm    
Hmm.
Sergey Alexandrovich Kryukov 5-Mar-15 18:51pm    
What "hmm"? I explained you all you really need in my answer. Just learn it and proceed, it should not be a problem to succeed...
—SA
chrisf8657 5-Mar-15 18:19pm    
If the coding gets too hard for you, you may look at some of the contributions others have made, use them, and also learn from them.

Specifcally, gLabel may help.

http://www.codeproject.com/KB/buttons/[^]
iProgramIt 5-Mar-15 18:27pm    
Alright, thanks

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900