在vb.net中显示父mdi表单状态栏中childform的datagridview的当前行

时间:2013-11-21 05:06:06

标签: vb.net datagridview mdi mdichild

以下是我已编码代码的要求。 当用户在数据网格视图中输入新行时,当前行应显示在父MDI表单的状态栏中,我已在其中放置一个标签,并在该标签文本中显示当前行的所有单元格值应显示。我具有以下内容儿童形式的代码,但它不工作。我还附上了mdi表单的图像以及子enter image description here表格

Private Sub dgsalesitem_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgsalesitem.Leave
    Dim X As DataGridViewCell
    Dim v As String
    v = ""
    For Each X In dgsalesitem.SelectedRows

        v = v + X.Value
    Next
    MDILoad.lbltoolstripstatus.Text = v

End Sub

1 个答案:

答案 0 :(得分:1)

试用此代码

Private Sub DataGridView1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Leave

        Dim x As String = String.Empty

        For xi As Integer = 0 To DataGridView1.ColumnCount - 1

            x += Trim(DataGridView1.CurrentRow.Cells(xi).Value)

        Next

        CType(Me.MdiParent, Object).ToolStripStatusLabel1.Text = x

    End Sub