【问题标题】:Code for a button that has a push-down effect? Vb.net具有下推效果的按钮的代码? VB.net
【发布时间】:2021-05-11 11:28:25
【问题描述】:

如何使按钮具有下推效果?我不是在谈论FlatStyle popup。它必须“向下”,可以这么说,在它被点击的那一秒内,当鼠标点击结束时“向上”。

这是迄今为止我尝试过的代码。你有更好的想法吗?

        Dim RememberXpos As Integer = Button1.Location.X
        Dim RememberYpos As Integer = Button1.Location.Y
        Dim ButtonXEnd As Integer = Button1.Location.X + Button1.Size.Width
        Dim ButtonYEnd As Integer = Button1.Location.Y + Button1.Size.Height
        Dim oldSize As Size = Button1.Size

        ' shrink
        Button1.Size = New Size(CInt(Button1.Size.Width * 0.9), CInt(Button1.Size.Height * 0.9))

        ' center the button
        Dim ButtonXEndeDiffHalf As Integer = CInt(Math.Round((ButtonXEnd - (Button1.Location.X + Button1.Size.Width)) / 2.0, 0))
        Dim ButtonYEndeDiffHalf As Integer = CInt(Math.Round((ButtonYEnd - (Button1.Location.Y + Button1.Size.Height)) / 2.0, 0))
        Button1.Location = New Point(Button1.Location.X + ButtonXEndeDiffHalf, Button1.Location.Y + ButtonYEndeDiffHalf)
        Button1.Update()
        System.Threading.Thread.Sleep(150)

        ' re-enlarge
        Button1.Size = oldSize
        Button1.Location = New Point(RememberXpos, RememberYpos)

【问题讨论】:

    标签: vb.net button controls mouseclick-event


    【解决方案1】:

    改用复选框并将外观设置为按钮。

    CheckBox1.Appearance = Appearance.Button
    

    【讨论】:

      猜你喜欢
      • 2011-07-09
      • 2020-08-11
      • 2019-07-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多