开发者

How to make custom buttons in vb.net [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 4 years ago.

Improve this question 开发者_Python百科

Do you know of any tutorial that could help me make a custom button in vb.net. Because visual studio 2008 doesn't allow you to create buttons in circle or triangular shapes. I've tried searching and found this one but, I cannot make use of it because there are lots of errors. http://www.codeproject.com/KB/buttons/CButton.aspx


you can use WPF to create any shape of Button.

see below URL

http://www.codeproject.com/KB/WPF/glassbuttons.aspx


Creating custom buttons of various shapes is super easy, Here is the basic code after you add a picture box to your form (picHome):

    Private Sub picHome_Click(sender As System.Object, e As System.EventArgs) Handles picHome.Click
        Try
            Dim tPic As PictureBox = DirectCast(sender, PictureBox)
            If Not IsNothing(tPic.Image) Then
                tPic.Image.Dispose()
                tPic.Image = Nothing
            End If
            tPic.Image = Global.CustomButton.My.Resources.btnDemoHome30_MOver
            lbMsg.Text = "HOME BUTTON CLICKED"
        Catch ex As Exception

        End Try
    End Sub

    Private Sub picHome_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles picHome.MouseDown
        Try
            Dim tPic As PictureBox = DirectCast(sender, PictureBox)
            If Not IsNothing(tPic.Image) Then
                tPic.Image.Dispose()
                tPic.Image = Nothing
            End If
            tPic.Image = Global.CustomButton.My.Resources.btnDemoHome30_MClick
        Catch ex As Exception

        End Try
    End Sub

    Private Sub picHome_MouseEnter(sender As Object, e As System.EventArgs) Handles picHome.MouseEnter
        Try
            Dim tPic As PictureBox = DirectCast(sender, PictureBox)
            If Not IsNothing(tPic.Image) Then
                tPic.Image.Dispose()
                tPic.Image = Nothing
            End If
            tPic.Image = Global.CustomButton.My.Resources.btnDemoHome30_MOver
            lbMsg.Text = "MOUSE OVER HOME BUTTON"
        Catch ex As Exception

        End Try
    End Sub

To see it in action watch this video tutorial https://www.youtube.com/watch?v=989M3qYrlKo , if you still have any questions post back here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜