简体   繁体   English

在c#中添加复选框在c#中

[英]Adding the check boxes in the TREEVIEW in c#

我想在我的应用程序的树视图中将复选框添加到某个父节点的子节点...我该如何添加它?

TreeView有一个名为CheckBoxes的属性,如果设置为true ,它会显示所有子节点的复选框。

The TreeView API only allows you to add/remove checkboxes for EVERY node. TreeView API仅允许您为每个节点添加/删除复选框。 If that's what you want, then the answer is easy - use the TreeView's CheckBoxes property. 如果这就是你想要的,那么答案很简单 - 使用TreeView的CheckBoxes属性。

If you want a checkbox for a particular node in the tree only, then it gets tricky. 如果您只想要树中特定节点的复选框,那么它会变得棘手。 .NET doesn't directly support that. .NET不直接支持它。 You can get the tree to accept it using Win32 message overrides, see the link below for a solution elsewhere: 您可以使用Win32消息覆盖使树接受它,请参阅下面的链接以获取其他地方的解决方案:

http://dotnetfollower.com/wordpress/2011/05/winforms-treeview-hide-checkbox-of-treenode/ http://dotnetfollower.com/wordpress/2011/05/winforms-treeview-hide-checkbox-of-treenode/

You can't show checkboxes only for some TreeNode s - only for all of them or none at all. 您不能仅为某些TreeNode显示复选框 - 仅适用于所有TreeNode或根本不显示。 To enable the checkboxes for your tree set the CheckBoxes property to true . 要启用树的复选框,请将CheckBoxes属性设置为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM