我有两个DataGridViews
在 Windows 窗体,VB.NET
当我双击FullSelectedRow
时DataGridView1
,SelectedRow
应该将 复制到DataGridView2
,两个网格都DataBounded
来自 SQL Server 2008..
这是我在每个网格中检索数据的代码..
**DataGridView1**
Dim UserScheduleString As String = "SELECT * FROM Schedule"
Dim UserScheduleStringList As New SqlCommand(UserScheduleString, mdl_Connection.CONN)
UserScheduleStringList.CommandType = CommandType.Text
UserScheduleStringListAdpt.SelectCommand = UserScheduleStringList
UserScheduleStringListAdpt.SelectCommand.ExecuteNonQuery()
UserScheduleStringListAdpt.Fill(UserScheduleStringListDataSet, "Users")
DataGridView1.DataSource = UserScheduleStringListDataSet.Tables("Users")
**DataGridView2**
Dim SomeTableString As String = "SELECT * FROM someTable"
Dim SomeTableStringList As New SqlCommand(SomeTableString, mdl_Connection.CONN)
SomeTableStringList.CommandType = CommandType.Text
SomeTableStringListAdpt.SelectCommand = SomeTableStringList
SomeTableStringListAdpt.SelectCommand.ExecuteNonQuery()
SomeTableStringListAdpt.FillSomeTableStringListDataSet, "*<tablename>*")
DataGridView1.DataSource = SomeTableStringListDataSet.Tables("*<tablename>*")
我搜索了其他论坛,这就是我所拥有的..
newCustomersRow = UserScheduleStringListDataSet.Tables("Users").NewRow()
newCustomersRow("ID") = "0023"
newCustomersRow("Day") = "Tuesday"
newCustomersRow("Start Time") = "13:00:00"
newCustomersRow("End Time") = "18:00:00"
UserScheduleStringListDataSet.Tables("Users").Rows.Add(newCustomersRow)
UserScheduleStringListAdpt.Update(UserScheduleStringListDataSet, "Users")
当我尝试将其放入时DataGridView1_CellMouseDoubleClick
,它给了我一个错误Object reference not set to an instance of an object.