主题:关于TreeView的问题
我有一个问题
一个treeview和一个datagrid控件
设计为一个根目录三个子目录,如何实现双击根目录或某一子目录时在datagrid中显示相应记录。
我只会做到下面的程度。帮我改改吧。万分感激!
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim strconn As String
strconn = "provider=SQLOLEDB; initial catalog=xj; Integrated security=SSPI;data source=(local);"
Dim cn As New OleDbConnection(strconn)
cn.Open()
Dim strSQL As String
strSQL = "select xj.学号,xj.姓名,xj.性别,class.年级,xj.班级,class.专业,class.年制,xj.出生年月,xj.家庭住址,xj.邮政编码,xj.联系电话,xj.入学时间,xj.备注 from xj inner join class on xj.班级=class.班级 where xj.班级='" & strSQL & "' or 年级='" & strSQL & "' order by class.年级 ,class.班级 ,xj.学号 "
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataReader = cmd.ExecuteReader()
Dim ds As New DataSet
DataGrid1.DataSource = ds
End Sub
一个treeview和一个datagrid控件
设计为一个根目录三个子目录,如何实现双击根目录或某一子目录时在datagrid中显示相应记录。
我只会做到下面的程度。帮我改改吧。万分感激!
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim strconn As String
strconn = "provider=SQLOLEDB; initial catalog=xj; Integrated security=SSPI;data source=(local);"
Dim cn As New OleDbConnection(strconn)
cn.Open()
Dim strSQL As String
strSQL = "select xj.学号,xj.姓名,xj.性别,class.年级,xj.班级,class.专业,class.年制,xj.出生年月,xj.家庭住址,xj.邮政编码,xj.联系电话,xj.入学时间,xj.备注 from xj inner join class on xj.班级=class.班级 where xj.班级='" & strSQL & "' or 年级='" & strSQL & "' order by class.年级 ,class.班级 ,xj.学号 "
Dim cmd As New OleDbCommand(strSQL, cn)
Dim da As OleDbDataReader = cmd.ExecuteReader()
Dim ds As New DataSet
DataGrid1.DataSource = ds
End Sub