我在网上搜索了如何使用输入到表单中的新数据“记录”填充DataGridView,然后使用BindingNavigator保存记录。 我有一个带有DataDridView的表单,我将表格列从DataSource拉到表单中,以便人们输入新记录。然后我想用信息填充DataGrid然后保存它。
Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click
Dim RR As Integer = ACCOUNT_MOVEDDataGridView.RowCount - 2
For RC As Integer = 0 To RR
If ACCOUNT_MOVEDDataGridView(2, RC).Value Is DBNull.Value Then
'' ACCOUNT_MOVEDDataGridView(2, RR).Value = ACCOUNT_MOVEDDataGridView(15, RR).Value = 0
End If
Next
End Sub
答案 0 :(得分:0)
我已经弄清楚了,我把代码放在BindingNavigatorAddNewItem_Click下 什么时候它应该在Save Item点击下。
Private Sub ACCOUNT_MOVEDBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles ACCOUNT_MOVEDBindingNavigatorSaveItem.Click
Call ACCDEF()
Private Sub ACCDEF()
Dim RR As Integer = ACCOUNT_MOVEDDataGridView.RowCount - 2
For RC As Integer = 0 To RR
If ACCOUNT_MOVEDDataGridView(2, RC).Value Is DBNull.Value Then
ACCOUNT_MOVEDDataGridView(2, RR).Value = Date.Now
ACCOUNT_MOVEDDataGridView(15, RR).Value = 0
Else
ACCOUNT_MOVEDDataGridView(1, RR).Value = Date.Now
End If
Next
End Sub
使用默认值加载DataGridView,感谢所有查看过我的问题。