0
在我的VB類新行我已經定義了這個屬性爲類變量:裏面插入的DataGridView
Friend WithEvents dgw As System.Windows.Forms.DataGridView
某處在同一個類中定義的屬性:
Private Sub mySub(...)
Dim aDataAdapter As SqlDataAdapter
Dim aDataSet = New DataSet
aDataAdapter = New SqlDataAdapter("exec something")
aDataAdapter.Fill(aDataSet)
Me.dgw.DataSource = aDataSet.Tables(0)
' [PLACEHOLDER]
End Sub
此代碼做的工作:數據來自數據庫並插入到網格中。現在,我將手動添加新的一行網格內,所以我在寫到位的[PLACEHOLDER]
此代碼:
Dim emptyRow As DataGridViewRow
emptyRow.SetValues(New String() {"a", "b", "c", "d", "e"})
Me.dgw.Rows.Insert(2, emptyRow)
,但沒有發生在DataGridView
(即插入任何行)。怎麼了?
我敢肯定,@ marianoc84已經做到了.. – matzone
沒有被添加到表中添加行:| –
@ marianoc84:它已更改..再試一次 – matzone