Deleting a record from the datagridview

前端 未结 2 1571
無奈伤痛
無奈伤痛 2021-01-16 21:37

In VB2012, I have a created a student management software with SQL2012 as the back-end. The below code is used for deleting a selected record from the datagridview when DELE

2条回答
  •  孤街浪徒
    2021-01-16 22:17

    the code below is also helpful

     Private Sub btnRemoveItem_Click(sender As Object, e As EventArgs) Handles btnRemoveItem.Click
            If datagridviewname.SelectedRows.Count > 0 Then
                For i As Integer = datagridviewname.SelectedRows.Count - 1 To 0 Step -1
                    datagridviewname.Rows.RemoveAt(datagridviewname.SelectedRows(i).Index)
                Next
            Else
                MessageBox.Show("Select Row to remove")
            End If
        End Sub
    

提交回复
热议问题