VScrollBar的Scroll事件处理函数
private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)ScrollEventArgs.ThumbTrack处理滚动条正在被移动的消息。
如何区分是在向上滚动还是向下滚动??

解决方案 »

  1.   

    OldValue 和NewValue 就可以判断了
      

  2.   

    在什么位置设置或者保存newValue 和oldValue。。
    那位能给个例子。。
      

  3.   

    private void AddMyScrollEventHandlers()
     {
        // Create and initialize a VScrollBar.
        VScrollBar vScrollBar1 = new VScrollBar();
     
        // Add event handlers for the OnScroll and OnValueChanged events.
        vScrollBar1.Scroll += new ScrollEventHandler(
           this.vScrollBar1_Scroll);
        vScrollBar1.ValueChanged += new EventHandler(
           this.vScrollBar1_ValueChanged); 
     }
     
     // Create the ValueChanged event handler.
     private void vScrollBar1_ValueChanged(Object sender, 
                                           EventArgs e)
     {
         // Display the new value in the label.
         label1.Text = "vScrollBar Value:(OnValueChanged Event) " + vScrollBar1.Value.ToString();
     }
     
     // Create the Scroll event handler.
     private void vScrollBar1_Scroll(Object sender, 
                                     ScrollEventArgs e)
     {
         // Display the new value in the label.
         label1.Text = "VScrollBar Value:(OnScroll Event) " + e.NewValue.ToString();
     }
     
     private void button1_Click(Object sender, 
                               EventArgs e)
     {
        // Add 40 to the Value property if it will not exceed the Maximum value.
        if (vScrollBar1.Value + 40 < vScrollBar1.Maximum)
        {
            vScrollBar1.Value = vScrollBar1.Value + 40;
        }
     }