有没有办法检测Grid Control垂直滚动条是可见还是隐藏。或者如果隐藏或可见,则返回值的属性?我目前正在使用开发快递网格控制任何人都可以提供答案吗?我一直在寻找几个小时,但我找不到答案。
答案 0 :(得分:1)
这适用于旧版本的DevExpress网格视图。我也使用标准反射得到null。
private GridViewInfo GetViewInfo(GridView view)
{
FieldInfo fi;
fi = typeof(GridView).GetField("fViewInfo", BindingFlags.NonPublic | BindingFlags.Instance);
GridViewInfo griInfo = fi.GetValue(view) as GridViewInfo;
if (griInfo != null)
{
// check if scrollbar
if (griInfo.VScrollBarPresence == ScrollBarPresence.Visible)
{
Console.WriteLine("Scrollbar visible");
}
else
{
Console.WriteLine("Scrollbar not visible");
}
}
return griInfo;
}
答案 1 :(得分:0)
网格控制不提供此类属性。你为什么不使用XtraScrollableControl?
答案 2 :(得分:0)
private void button1_Click(object sender, EventArgs e)
{
// create a long list to force scrollbar
List<String> tempList = new List<string> { "1 value", "1 value", "1 value", "1 value", "1 value", "1 value", "1 value", "1 value", "1 value", "1 value", "1 value", "1 value", "1 value" };
gridControl1.DataSource = tempList;
// check if scrollbar is visible
GridViewInfo viewInfo = gridView1.GetViewInfo() as GridViewInfo;
if (viewInfo != null)
{
// check if scrollbar
if (viewInfo.VScrollBarPresence == ScrollBarPresence.Visible)
{
Console.WriteLine("Scrollbar visible");
}
else
{
Console.WriteLine("Scrollbar not visible");
}
}
}
来源:DevExpress