求各位大神帮忙,解释一下这段代码??
这是我们老师上课讲的一段代码,没听懂,想请问给位前辈来给我说明一下这段代码的具体各行有什么具体的意思??给我做一下注释呗??谢谢啦!
Public Class Form1
Sub inittree()
Dim o As New Class1
Dim dr As SqlDataReader
dr = o.getalldata()
While dr.Read
Dim iItem As New System.Windows.Forms.TreeNode
iItem.Text = RTrim(dr!fullname.ToString)
iItem.Name = RTrim(dr!typeid.ToString)
Try
iItem.ImageIndex = 0
iItem.SelectedImageIndex = 1
Catch ex As Exception
MsgBox(ex.Message)
End Try
If Val(dr!isgroup) = 1 Then
iItem.Tag = ""
Else
iItem.Tag = dr!form.ToString
End If
If RTrim(dr!parid.ToString) = "0" Then
Me.TreeView1.Nodes.Add(iItem)
Else
If Me.TreeView1.Nodes.Find(RTrim(dr!parid.ToString), True).Length > 0 Then
Me.TreeView1.Nodes.Find(RTrim(dr!parid.ToString), True)(0).Nodes.Add(iItem)
End If
End If
End While
dr.Close()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
inittree()
'Me.TreeView1.ExpandAll()
End Sub
Private Sub TreeView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DoubleClick
If Not Me.TreeView1.SelectedNode Is Nothing And Me.TreeView1.SelectedNode.Tag <> "" Then
Dim frmname As String
frmname = Trim(Me.TreeView1.SelectedNode.Tag)
Dim f As New Form
'f = CType(Activator.CreateInstance(Type.GetType(frmname)), Form)
f = Activator.CreateInstance(Type.GetType(frmname, True, True))
f.WindowState = FormWindowState.Maximized
f.MdiParent = Me
f.Text = Me.TreeView1.SelectedNode.Text
f.Show()
End If
End Sub
End Class
[解决办法]
该回复于2013-12-08 09:56:38被管理员删除