自定义控件,我设置了AutoScrollMinSize的大小,所以会出现滚动条,右击滚动条,有个菜单,上有顶部、底部、向上翻页、向下翻页等,请问如何用代码实现这些功能??

解决方案 »

  1.   

    用api函数去控制,参考http://blog.csdn.net/achellies/article/details/6193059
      

  2.   

    得到鼠标点知位置,然后设置滚动条位置
     foreach (Control controls in groupbox.Controls)
                {
                    if (controls is VScrollBar) continue;
                    controls.Tag = controls.Location.Y;
                }
      

  3.   

    用api函数去控制滚动条
    这是我实现代码
     public struct SCROLLINFO
            {
                public uint cbSize;            public uint fMask;            public int nMin;            public int nMax;            public uint nPage;            public int nPos;            public int nTrackPos;
            }
            [DllImport("user32.dll", EntryPoint = "GetScrollInfo")]        public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi);
    SCROLLINFO si = new SCROLLINFO();bool result = GetScrollInfo(intPtr, 1, ref si);为什么result 总是false???
      

  4.   

    直接发送消息就可以实现了
     const int WM_VSCROLL = (int)0x0115;
    SendMessage(this.Handle, WM_VSCROLL, (int)ScrollBarRequests.SB_TOP, 0);