panel 中动态添加控件后的问题 Me.Panel1.AutoScrollPosition = New Point(x,y)不过一般不需要用代码,可以用control.select就可以自动滚动到控件所在的区域 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Brunhild()你的代码好像是vb的,我在c#这样用不管用,不知道为什么,this.panel1.AutoScrollPosition=new Point(20,-76) ;不管new Point(20,-76)的值是多少,都滚到顶部!能说说为什么吗? this.ScrollControlIntoView(FormControl); sorry:这样:this.panel1.ScrollControlIntoView(control); 有一个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); } hbxtlhx(下着春雨的天) this.ScrollControlIntoView(FormControl);this.panel1.ScrollControlIntoView(control);依然不好用,我把它放到button的click事件中部好用。Brunhild() 的control.select 放到到button的click事件中好用,但在函数中不好用,不知道为什么,它需要,把焦点移开后才起作用 用如下的代码就可以了: [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); } hbxtlhx(下着春雨的天) Brunhild() 感谢两位的热情,每人10分,我不知道到怎么再加分只好按20分给,如果有疑问也就是说还想要分,和我说,我不吝啬的给你,告诉我怎么给就好了我的email:[email protected] 我就是用的control.select方法实现的。 C# 多线程问题! C# 远程监控其他网段内电脑。 .net能否直接打印cad文件 保存调用的程序 如何在设计模式下创建控件数组啊? 在FormLoad里的线程 和 在WndProc里的线程为什么不同呢? 数据库问题,一个sql数据库原来只有一张表,现在想分为多表。主要是数据库量太大。怎么效率才会高呢? C#,Panel里添加的控件,左右选择时首尾巴相接的问题 类方法的返回类型可以是任意类型的吗? 哪位有图书馆管理系统的C#源程序? 什么方法可以实现两个日期之间有多少个月 安装程序问题
this.panel1.AutoScrollPosition=new Point(20,-76) ;
不管new Point(20,-76)的值是多少,都滚到顶部!能说说为什么吗?
这样:
this.panel1.ScrollControlIntoView(control);
[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);
}
this.ScrollControlIntoView(FormControl);
this.panel1.ScrollControlIntoView(control);
依然不好用,我把它放到button的click事件中部好用。Brunhild() 的
control.select 放到到button的click事件中好用,但在函数中不好用,不知道为什么,它需要,把焦点移开后才起作用
[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);
}
Brunhild()
感谢两位的热情,每人10分,我不知道到怎么再加分只好按20分给,如果有疑问也就是说还想要分,和我说,我不吝啬的给你,告诉我怎么给就好了我的email:[email protected]