gpt4 book ai didi

c# - Windows 窗体/ TreeView : How do I put CheckBoxes only on the leaves?

转载 作者:太空宇宙 更新时间:2023-11-03 22:06:50 25 4
gpt4 key购买 nike

在 TreeView 上选择 CheckBoxes=true 会在每个节点上放置复选框。我只想要它们在叶子上?怎么办?

最佳答案

我认为您需要像这样为节点实现一个 ownerdraw 事件处理程序:

treeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
treeView.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeView_DrawNode);

private void treeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
if(NodeWithCheckBox(e.Node))
{
// draw entry with checkbox
e.DrawDefault = false;
}
else
{
e.DrawDefault = true;
}
}

关于c# - Windows 窗体/ TreeView : How do I put CheckBoxes only on the leaves?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8147209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com