Phi*_*son 14 c# treeview winforms
我有一个TreeView,允许用户通过选中或取消选中每个项目的复选框来选择分层数据的某些元素.目前,我在有孩子的节点上禁用了使用其他问题的复选框隐藏技术的框,如下所示:
? Node 1
? Node 2
• Node 3
? Node 3.1
? Node 3.2
• Node 4
? Node 4.1
? Node 4.2
Run Code Online (Sandbox Code Playgroud)
但更好的解决方案是为父节点使用三态复选框,如下所示:
? Node 1
? Node 2
? Node 3
? Node 3.1
? Node 3.2
? Node 4
? Node 4.1
? Node 4.2
Run Code Online (Sandbox Code Playgroud)
由于此功能在Win32中可用,我的问题是如何在不自己绘制框的情况下执行此操作(例如,作为用户绘制的控件或使用图像列表).我根本不熟悉Win32 API; 如何扩展上面链接的技术以在托管的TreeView控件上启用三态checbox?
Hom*_*mam 13
如果您正在考虑绘制混合复选框,此代码可能会对您有所帮助
class MixedCheckBox:Control
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(0, 0), Bounds,
Text, Font, false,
System.Windows.Forms.VisualStyles.CheckBoxState.MixedNormal);
}
}
Run Code Online (Sandbox Code Playgroud)
这将呈现: 
祝好运!
| 归档时间: |
|
| 查看次数: |
17456 次 |
| 最近记录: |