جربت كما تفضلت لكن لازال المؤشر يذهب لأعلى ..
وهذا الكود بعد التعديل ...
Try
Dim CurrentRowIndex As Integer = DGV_Users.CurrentRow.Index
' 'لتأكيد عملية الحذف
' If MsgBox("هل تريد تأكيد عملية الحذف", MsgBoxStyle.YesNo, "تأكيد الحذف") = DialogResult.Yes Then
' sqlstr = "Delete From TB_Notices Where ID_Format = @ID_Format"
' cmd = New OleDbCommand(sqlstr, conn)
' cmd.Parameters.Add("@ID_Format", OleDbType.VarChar).Value = DGVAlert.CurrentRow.Cells(1).Value
' conn.Open()
' cmd.ExecuteNonQuery()
' MsgBox("تمت عملية الحذف بنجاح", MsgBoxStyle.Information, "الحذف")
' 'سب تحميل البيانات
' FillDGVAlert()
DGV_Users.Rows(CurrentRowIndex).Selected = True
DGV_Users.FirstDisplayedScrollingRowIndex = CurrentRowIndex
' End If
'Catch ex As Exception
' MsgBox("لا توجد تنبيهات معلقة", MsgBoxStyle.Information, "حذف تنبيه")
'Finally
' conn.Close()
'End Try
وهذا الكود بعد التعديل ...
Try
Dim CurrentRowIndex As Integer = DGV_Users.CurrentRow.Index
' 'لتأكيد عملية الحذف
' If MsgBox("هل تريد تأكيد عملية الحذف", MsgBoxStyle.YesNo, "تأكيد الحذف") = DialogResult.Yes Then
' sqlstr = "Delete From TB_Notices Where ID_Format = @ID_Format"
' cmd = New OleDbCommand(sqlstr, conn)
' cmd.Parameters.Add("@ID_Format", OleDbType.VarChar).Value = DGVAlert.CurrentRow.Cells(1).Value
' conn.Open()
' cmd.ExecuteNonQuery()
' MsgBox("تمت عملية الحذف بنجاح", MsgBoxStyle.Information, "الحذف")
' 'سب تحميل البيانات
' FillDGVAlert()
DGV_Users.Rows(CurrentRowIndex).Selected = True
DGV_Users.FirstDisplayedScrollingRowIndex = CurrentRowIndex
' End If
'Catch ex As Exception
' MsgBox("لا توجد تنبيهات معلقة", MsgBoxStyle.Information, "حذف تنبيه")
'Finally
' conn.Close()
'End Try