【问题标题】:VB 2013 load datagridview from a formVB 2013 从表单加载 datagridview
【发布时间】:2016-05-12 17:14:04
【问题描述】:

我在网上搜索了如何使用输入到表单中的新数据“记录”填充 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

【问题讨论】:

  • 你没有问问题。你想解决什么问题?我们可能需要查看代码来帮助您。
  • @svarg 我试过这段代码。
  • 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)。值为 DBNull.Value Then '' ACCOUNT_MOVEDDataGridView(2, RR).Value = ACCOUNT_MOVEDDataGridView(15, RR).Value = 0 End If Next End Sub
  • 抱歉我第一次发帖缩进了4次
  • 您不能在 cmets 中设置代码。请用您的代码编辑您的问题

标签: vb.net


【解决方案1】:

我想通了,我把代码放在 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,感谢所有查看我的问题的人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多