3/2/11
Save Data Grid Data
If DataGridView1.Rows.Count > 0 Then
Dim r As DataGridViewRow
For Each r In DataGridView1.Rows
Dim db As New DBAccess
Dim strSQL As String
strSQL = "INSERT INTO [dbo].[Table_2] ([name1] ,[id1]) VALUES ( '" & r.Cells(0).Value & "'," & r.Cells(3).Value & " )"
db.ExecuteScalar(strSQL, Data.CommandType.Text)
db.CloseDB()
Next
End If
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
Subscribe to:
Posts (Atom)