You can accomplish it without reloading the grid as well, using
DataView and
Currency Manager object. Try the following code, make appropriate changes
'Declare class level variable.
Dim objDV As DataView
Dim objCM As CurrencyManager
Private Sub PopulateDataGrid()
Dim selectString As String
Dim objDA As OleDbDataAdapter
Dim objDS As New DataSet()
Try
'Initialize the SQL string.
selectString = "Your SQL SELECT statement"
'Initialize the OleDbDataAdapter object and fill DataSet.
objDA = New OleDbDataAdapter(selectString, MyConnection)
objDA.Fill(objDS, "yourTableName"
'Set the DataView object to the DataSet object.
myDV = New DataView(objDS.Tables("yourTableName"

)
'Set our CurrencyManager object to the DataView object.
objCM = CType(Me.BindingContext(myDV), CurrencyManager)
myDataGrid.DataSource = myDV
Catch Excep As System.Exception
MessageBox.Show(Excep.Message, "Prospect Management System (srcPros)", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub onDeleteClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Are you sure to delete this record?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
'Call your delete procedure
DeleteProspect()
'Remove deleted row from the DataGrid.
myDV.Delete(myCurrencyManager.Position)
End If
End Sub
Email: pankajmsm@yahoo.com