Nápad dle doporučení konkurenčního fóra:
Public Class Form1
Dim WithEvents tv As TreeView
Dim lv As ListView
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
tv = New TreeView
tv.Dock = DockStyle.Fill
lv = New ListView
lv.Dock = DockStyle.Fill
Dim nd As TreeNode = tv.Nodes.Add("ABC")
For i As Integer = 1 To 3
Dim nc As TreeNode = nd.Nodes.Add(nd.Text & i.ToString, nd.Text & i.ToString)
If i = 2 Then
nc.ForeColor = Color.Gray
End If
Next
nd.ExpandAll()
Dim sc As SplitContainer = New SplitContainer
With sc
.Panel1.Controls.Add(tv)
.Panel2.Controls.Add(lv)
.Dock = DockStyle.Fill
End With
Me.Controls.Add(sc)
End Sub
Private Sub tv_BeforeSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles tv.BeforeSelect
If e.Node.ForeColor = Color.Gray Then
e.Cancel = True
End If
End Sub
End Class
Samozřejmě je to nedokonalé, ještě enabled a disabled ikony, všechny childnode disabled automaticky je-li parentnode disabled apod. ... Chce to vypiplat do vb6 šílenosti. :) Mnoho zdaru!
|