我正在开发一个应用程序,需要ListBox
控制。不幸的是,当我在中添加太多项目时ListBox
,显示垂直滚动条。我可以做些什么来隐藏显示的垂直滚动条ListBox
?我可以看到有一个隐藏水平滚动条的属性,但没有垂直滚动条的属性。
问题解决了。我只是使用以下代码创建了一个模板类库的新项目
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class MyListBox : System.Windows.Forms.ListBox
{
private bool mShowScroll;
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
if (!mShowScroll)
cp.Style = cp.Style & ~0x200000;
return cp;
}
}
public bool ShowScrollbar
{
get { return mShowScroll; }
set
{
if (value != mShowScroll)
{
mShowScroll = value;
if (IsHandleCreated)
RecreateHandle();
}
}
}
}
}
然后,我构建了输出新类库的项目ClassLibrary1.dll
在我的主项目中,我右键单击了ToolBox
并选择了Choose Items...
。点击了浏览...并选择我最近创建的类库(ClassLibrary1.dll)并单击Open然后OK。因此,我能够拥有我的习惯ListBox
它不再有垂直滚动条了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)