none
HscrollBar值變動事件 RRS feed

  • 問題

  •  

    請問各位學長,我在拉動Hscrollbar時,會一直觸發ValueChanged的事件,

    我希望在我把滑鼠按鈕放開後才觸發事件,請問該怎麼做?

     

    2008年8月29日 上午 10:35

解答

  • 試試MouseLeave事件

        Dim OriginalValueOfHScrollBar As Int32 = 0
        Private Sub HScrollBar1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBar1.MouseLeave
            If HScrollBar1.Value <> OriginalValueOfHScrollBar Then
                OriginalValueOfHScrollBar = HScrollBar1.Value
                Debug.Print("MouseLeave, HScrollBarValue=" & HScrollBar1.Value.ToString)
            End If
        End Sub

    2008年8月30日 上午 03:27
  •  C.K.Tsai 寫信:
    試試MouseLeave事件

        Dim OriginalValueOfHScrollBar As Int32 = 0
        Private Sub HScrollBar1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBar1.MouseLeave
            If HScrollBar1.Value <> OriginalValueOfHScrollBar Then
                OriginalValueOfHScrollBar = HScrollBar1.Value
                Debug.Print("MouseLeave, HScrollBarValue=" & HScrollBar1.Value.ToString)
            End If
        End Sub

     

     

    試試MouseCaptureChanged事件

    這個事件不必等到滑鼠離開控制項才會觸發

    而是你選完後,放開滑鼠才觸發

        Private Sub VScrollBar1_MouseCaptureChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VScrollBar1.MouseCaptureChanged
            Me.Text = CType(sender, VScrollBar).Value
        End Sub

    2008年8月30日 上午 11:56

所有回覆

  • 試試MouseLeave事件

        Dim OriginalValueOfHScrollBar As Int32 = 0
        Private Sub HScrollBar1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBar1.MouseLeave
            If HScrollBar1.Value <> OriginalValueOfHScrollBar Then
                OriginalValueOfHScrollBar = HScrollBar1.Value
                Debug.Print("MouseLeave, HScrollBarValue=" & HScrollBar1.Value.ToString)
            End If
        End Sub

    2008年8月30日 上午 03:27
  •  C.K.Tsai 寫信:
    試試MouseLeave事件

        Dim OriginalValueOfHScrollBar As Int32 = 0
        Private Sub HScrollBar1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBar1.MouseLeave
            If HScrollBar1.Value <> OriginalValueOfHScrollBar Then
                OriginalValueOfHScrollBar = HScrollBar1.Value
                Debug.Print("MouseLeave, HScrollBarValue=" & HScrollBar1.Value.ToString)
            End If
        End Sub

     

     

    試試MouseCaptureChanged事件

    這個事件不必等到滑鼠離開控制項才會觸發

    而是你選完後,放開滑鼠才觸發

        Private Sub VScrollBar1_MouseCaptureChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VScrollBar1.MouseCaptureChanged
            Me.Text = CType(sender, VScrollBar).Value
        End Sub

    2008年8月30日 上午 11:56