选中treeview中某节点的部分子节点后,该节点的复选框上打勾,并显示为半透明状态。
有点像安装程序中的treeview的样子:安装部分模块,复选框即显示为半透明打勾;安装全部模块,复选框即正常显示,不透明打勾。
vs2005

解决方案 »

  1.   

    winform?
    是不是实现Node在勾选和不勾选两种状态下的颜色不同而已?
      

  2.   

    Three State TreeView:
    http://www.codeproject.com/KB/miscctrl/Three_State_TreeView.aspx
      

  3.   

    Enable = false;
    Checked = ture;
      

  4.   

    应该是winform,实现Node在勾选和不勾选两种状态下的颜色不同!!
      

  5.   

    如果仅仅是改变两种状态下的颜色,可以这么简单实现
    Public Class Form1    Private TestTree As New MyTree    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            For i As Integer = 0 To 10
                TestTree.Nodes.Add("Node" + i.ToString)
            Next
            Me.Controls.Add(TestTree)
            TestTree.Dock = DockStyle.Fill
        End SubEnd ClassPublic Class MyTree
        Inherits TreeView    Dim NodeStringFormat As StringFormat    Public Sub New()
            NodeStringFormat = New StringFormat
            NodeStringFormat.LineAlignment = StringAlignment.Center : NodeStringFormat.Alignment = StringAlignment.Center        Me.DrawMode = TreeViewDrawMode.OwnerDrawText
            Me.CheckBoxes = True
        End Sub    Private Sub MyTreeView_DrawNode(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawTreeNodeEventArgs) Handles Me.DrawNode
            If e.Node.Checked Then
                e.Graphics.DrawString(e.Node.Text, Me.Font, Brushes.Black, e.Bounds, NodeStringFormat)
            Else
                Dim r As New Rectangle(e.Bounds.Left - 13, e.Bounds.Top + 1, 13, 13)            ControlPaint.DrawCheckBox(e.Graphics, r, ButtonState.Inactive)
                e.Graphics.DrawString(e.Node.Text, Me.Font, Brushes.Gray, e.Bounds, NodeStringFormat)
            End If    End Sub   
    End Class
      

  6.   

    CheckBox有三种状态,Checked Unchecked Indeterminate 。你所说这半透明应该是指第三种状态Indeterminate 吧