I have one form that is having Scrollbar, i want to disable the scroll button that is present in vertical scroll bar with single click up and down movement buttons working...
can any one help me in this?
尝试这个 ...
VScrollBar vsb = DataGridView1.Controls.OfType(Of(VScrollBar)).SingleOrDefault;
vsb.LargeChange = vsb.SmallChange;
你会在这里找到答案:Hide vertical scroll bar in ListBox control
基本上,您无法隐藏它。如果需要,您只能使其始终显示或自动显示。否则,您可能需要制作自定义控件来执行您想要的操作。
该链接还向您展示了如何创建一个类库来执行此操作(直接取自链接):
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)
return;
mShowScroll = value;
if (Handle != IntPtr.Zero)
RecreateHandle();
}
}
}
}