ram*_*oti 1 .net c# collections propertygrid
任何带有长字符串的东西只会引入一个带滚动条的不可用视图.
集合编辑器的宽度是否由设计修复,并且可以在这个令人敬畏的演示文稿中引入分割器吗?
我没有看到通过常规方式做到这一点的方法PropertyGrid,但如果你不介意付费,Visualhint 在这里有一个更加发达的产品- 也许试用它.
这使用反射来完成工作; 谨慎使用......
using System;
using System.Reflection;
using System.Windows.Forms;
class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Form form = new Form();
// this bar will control the splitter
ScrollBar sb = new HScrollBar {
Minimum = 10, Maximum = 200,
Dock = DockStyle.Bottom
};
// the grid we want to control
PropertyGrid grid = new PropertyGrid {
SelectedObject = form, Dock = DockStyle.Fill
};
// add to the form
form.Controls.Add(grid);
form.Controls.Add(sb);
// event to update the grid
sb.ValueChanged += delegate {
MoveSplitterTo(grid, sb.Value);
};
Application.Run(form);
}
static void MoveSplitterTo(PropertyGrid grid, int x) {
// HEALTH WARNING: reflection can be brittle...
FieldInfo field = typeof(PropertyGrid)
.GetField("gridView",
BindingFlags.NonPublic | BindingFlags.Instance);
field.FieldType
.GetMethod("MoveSplitterTo",
BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(field.GetValue(grid), new object[] { x });
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2620 次 |
| 最近记录: |