Me.Panel1.AutoScrollPosition = New Point(x,y)
不过一般不需要用代码,可以用control.select就可以自动滚动到控件所在的区域

解决方案 »

  1.   

    Brunhild()你的代码好像是vb的,我在c#这样用不管用,不知道为什么,
    this.panel1.AutoScrollPosition=new Point(20,-76) ;
    不管new Point(20,-76)的值是多少,都滚到顶部!能说说为什么吗?
      

  2.   

    this.ScrollControlIntoView(FormControl);
      

  3.   

    sorry:
    这样:
    this.panel1.ScrollControlIntoView(control);
      

  4.   

    有一个API的方法:
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern int  SetScrollPos(          IntPtr hWnd,
    int nBar,
    int nPos,
    bool bRedraw
    ); private void button1_Click(object sender, System.EventArgs e)
    {
    SetScrollPos(this.panel1.Handle, 1, 70, true);
    }
      

  5.   

    hbxtlhx(下着春雨的天) 
    this.ScrollControlIntoView(FormControl);
    this.panel1.ScrollControlIntoView(control);
    依然不好用,我把它放到button的click事件中部好用。Brunhild() 的
    control.select 放到到button的click事件中好用,但在函数中不好用,不知道为什么,它需要,把焦点移开后才起作用
      

  6.   

    用如下的代码就可以了:
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    public static extern int SendMessage(IntPtr hwnd  ,int wMsg ,int wParam ,int  lParam );
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    public static extern bool UpdateWindow(IntPtr hWnd);  // handle to window
    //几个参考的值,实际上可以为任意在范围内的指定的数值.
    private const int WM_VSCROLL  = 0x115;
    private const int SB_LINEDOWN = 1;
    private const int SB_BOTTOM = 7; private void SelfSrcoll(IntPtr handle)
    {
    //SendMessage(handle, WM_VSCROLL, 100,0);
    SendMessage(handle, WM_VSCROLL, SB_BOTTOM,0);
    UpdateWindow(handle);
    }
    private void button1_Click(object sender, System.EventArgs e)
    {
    SelfSrcoll(this.panel1.Handle);
    }
      

  7.   

    hbxtlhx(下着春雨的天) 
    Brunhild() 
    感谢两位的热情,每人10分,我不知道到怎么再加分只好按20分给,如果有疑问也就是说还想要分,和我说,我不吝啬的给你,告诉我怎么给就好了我的email:[email protected]
      

  8.   

    我就是用的control.select方法实现的。