i used this code to delete row from datagridview but it dosnt delete the selected row it delete the first row , where is the problem??

    Dim sCommand As SqlCommand
    Dim sAdapter As SqlDataAdapter
    Dim sBuilder As SqlCommandBuilder
    Dim sDs As DataSet
    Dim sTable As DataTable


  Dim connectionString As String = "Data Source=HABOUSH-PC\SQLEXPRESS;Initial Catalog=TenderingSystem;Integrated Security=True"
        Dim sql As String = "SELECT * FROM BOQDetailEntry"
        Dim connection As New SqlConnection(connectionString)
        sCommand = New SqlCommand(sql, connection)
        sAdapter = New SqlDataAdapter(sCommand)
        sBuilder = New SqlCommandBuilder(sAdapter)
        sDs = New DataSet()
        sAdapter.Fill(sDs, "BOQDetailEntry")
        sTable = sDs.Tables("BOQDetailEntry")


        BOQDetailEntryDGV.DataSource = sDs.Tables("BOQDetailEntry")


 Dim i As Integer
        i = BOQDetailEntryDGV.CurrentRow.Index
        If MessageBox.Show("Are You sure you want to delete " + BOQDetailEntryDGV(4, i).Value().ToString + " Entry ?", "Warning Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.OK Then
            Catch ex As Exception
                MessageBox.Show("No record deleted")
            End Try
        End If

What selection mode is your datagrid using? If it is rowselect I think you will have use SelectedRows instead of CurrentRow, CurrentRow gets the row of the current selected cell but if you are using the rowselect mode you have not selected a cell but a row and so you will always get a zero.

This question has already been answered. Start a new discussion instead.