在树视图中选择CheckBoxes = true会在每个节点上放置复选框。我只想要它们在树叶上?怎么样?
答案 0 :(得分:2)
我认为您需要为节点实现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;
}
}
答案 1 :(得分:2)