3/2/11
color tree node on specific condition
color tree node on specific condition
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TreeView1.Nodes.Add("222")
TreeView1.Nodes(0).Nodes.Add("ABC12")
TreeView1.Nodes(0).Nodes.Add("ABC13")
TreeView1.Nodes(0).Nodes.Add("ABC14")
TreeView1.Nodes(0).Nodes(0).Nodes.Add("ABC121")
TreeView1.Nodes(0).Nodes(0).Nodes(0).Nodes.Add("ABC122")
TreeView1.Nodes(0).Nodes(0).Nodes(0).Nodes(0).Nodes.Add("222")
TreeView1.Nodes(0).Nodes(0).Nodes(0).Nodes.Add("333")
TreeView1.Nodes(0).Nodes(0).Nodes.Add("ABC123")
TreeView1.Nodes(0).Nodes(1).Nodes.Add("ABC131")
TreeView1.Nodes(0).Nodes(1).Nodes(0).Nodes.Add("222")
TreeView1.Nodes(0).Nodes(2).Nodes.Add("ABC121")
TreeView1.Nodes(0).Nodes(2).Nodes.Add("111")
TreeView1.Nodes(0).Nodes.Add("222")
TreeView1.ExpandAll()
If TreeView1.Nodes.Count > 0 Then
For Each tnode As TreeNode In TreeView1.Nodes
nodechk(tnode)
Next
End If
End Sub
Sub nodechk(ByVal m11 As TreeNode)
apply(m11)
If m11.Nodes.Count > 0 Then
For Each m1 In m11.Nodes
nodechk(m1)
Next
End If
End Sub
Sub apply(ByVal m1 As TreeNode)
If m1.Text = "ABC121" Then
m1.BackColor = Color.OrangeRed
m1.ForeColor = Color.White
Dim f As Font = New Font("verdana", 9, FontStyle.Bold)
m1.NodeFont = f
End If
If m1.Text = "222" Then
m1.BackColor = Color.Green
m1.ForeColor = Color.White
Dim f As Font = New Font("verdana", 9, FontStyle.Bold)
m1.NodeFont = f
End If
End Sub
On textbox key down /focus help shd open
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.F1 Then
Panel1.Visible = True
TextBox1.Enabled = False
TextBox2.Focus()
End If
End Sub
Private Sub TextBox2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Leave
If TextBox2.Text <> "" Then
Panel1.Visible = False
TextBox1.Enabled = True
TextBox1.Text = TextBox2.Text
End If
End Sub
Subscribe to:
Posts (Atom)