C#隐藏滚动条.

在Form里 AutoScroll后..会出现两个滚动条...有些时候我们只需要1个滚动条.

 

使用方法

 

 SetScrollBar(this.Handle,1, 0);

 

 

下面是全部代码

 

 

 

  [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int ShowScrollBar(IntPtr hWnd, int bar, int show); private class SubWindow : NativeWindow { private int m_Horz = 0; private int m_Show = 0; public SubWindow(int p_Horz, int p_Show) { m_Horz = p_Horz; m_Show = p_Show; } protected override void WndProc(ref Message m_Msg) { ShowScrollBar(m_Msg.HWnd, m_Horz, m_Show); base.WndProc(ref m_Msg); } } /// <summary> /// 设置滚动条是否显示 [email protected] qq:116149 /// </summary> /// <param name="p_ControlHandle">句柄</param> /// <param name="p_Horz">0横 1列 3全部</param> /// <param name="p_Show">0隐 1显</param> public static void SetScrollBar(IntPtr p_ControlHandle, int p_Horz, int p_Show) { SubWindow _SubWindow = new SubWindow(p_Horz, p_Show); _SubWindow.AssignHandle(p_ControlHandle); }

 

你可能感兴趣的:(qq,C#,user,Class)