Winforms有一个名为PropertyGrid
的控件。PropertyGrid
的显示元素是一个描述区域。默认情况下,它显示所选属性的名称。使用属性,程序员可以让它显示其他文本。我想把它完全移除。它占用了太多的空间,我不需要让它显示任何东西。我在对象模型中没有看到任何要删除它的属性。请张贴一个解决方案,以消除它。
下面是我所说的屏幕截图。我想移除红色的区域,这样"PercentComplete“就在帧的底部。
发布于 2015-04-27 01:12:28
尝试将PropertyGrid
的HelpVisible
属性设置为false
。
发布于 2015-04-27 00:34:18
在代码中添加以下内容:
private static void ChangeDescriptionHeight(PropertyGrid grid, int height)
{
if (grid == null) throw new ArgumentNullException("grid");
foreach (Control control in grid.Controls)
{
if (control.GetType().Name == "DocComment")
{
var fieldInfo = control.GetType().BaseType.GetField("userSized",
BindingFlags.Instance |
BindingFlags.NonPublic);
fieldInfo.SetValue(control, true);
control.Height = height;
return;
}
}
}
就这样叫它:
var progressTimerProperties = new ProgressTimerProperties();
propertyGridProgressTimer.SelectedObject = progressTimerProperties;
ChangeDescriptionHeight(propertyGridProgressTimer, 0);
注意到“0”了吗?它将描述区域的高度设置为0,有效地删除了它。如果你想,你可以走相反的方向,使它更大,以容纳更多的文本。
https://stackoverflow.com/questions/29884237
复制相似问题