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