.net datagrid

增行减行:
        Private Sub BtnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnInsert.Click
            If Me.GrdDetailInfo.CurrentRow Is Nothing Then

                Me.GrdDetailInfo.Rows.Add()

            Else
                Me.GrdDetailInfo.Rows.Insert(Me.GrdDetailInfo.CurrentRow.Index)
            End If
        End Sub

        Private Sub BtnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDel.Click
            If Me.GrdDetailInfo.CurrentRow Is Nothing Or Me.GrdDetailInfo.RowCount - 1 = Me.GrdDetailInfo.CurrentRow.Index Then
                Return
            End If
           Me.GrdDetailInfo.Rows.RemoveAt(GrdDetailInfo.CurrentRow.Index)
        End Sub

你可能感兴趣的:(.net datagrid)