|
-
Aug 25th, 2010, 11:08 AM
#1
Thread Starter
Member
[RESOLVED] Cancel selection changed in datagridview
Hi all,
Ive got a datagridview, which the user can put in to 'edit' mode by double clicking. If they then make changes but click to another row, I want to msg asking if they are sure they want to discard then changes. If they say No I want to stop the selection change from being made.
Code:
Private Sub DataGridView1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
If edit = True Then
Dim result As String = MsgBox("Are you sure you want to discard your changes?", MsgBoxStyle.YesNo)
If result = vbYes Then
clearedit()
Else
'Here is where I need to cancel the selection change
End If
Else
clearedit()
End If
-
Aug 25th, 2010, 11:17 AM
#2
Hyperactive Member
Re: Cancel selection changed in datagridview
I dont understand.
You wanna your datagridview pass to read only again??
-
Aug 25th, 2010, 11:18 AM
#3
Thread Starter
Member
Re: Cancel selection changed in datagridview
No, maybe I confused you by saying edit mode... ignore that!
How do I go back to the previous selected row on the selection changed event.
-
Sep 1st, 2010, 04:11 AM
#4
Thread Starter
Member
Re: Cancel selection changed in datagridview
-
Sep 1st, 2010, 08:18 AM
#5
Re: Cancel selection changed in datagridview
Store the row number then restore it:
Code:
grdComplete.Rows(intRow).Selected = True
grdComplete = DataGridView
intRow = index of the row that was being edited.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Sep 1st, 2010, 08:19 AM
#6
Thread Starter
Member
Re: Cancel selection changed in datagridview
-
Sep 1st, 2010, 09:30 AM
#7
Thread Starter
Member
Re: Cancel selection changed in datagridview
Cant give you rep again MarMan
-
Sep 1st, 2010, 09:43 AM
#8
Re: [RESOLVED] Cancel selection changed in datagridview
That's OK. The appreciation is appreciated.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Sep 1st, 2010, 09:45 AM
#9
Thread Starter
Member
Re: [RESOLVED] Cancel selection changed in datagridview
Just took a different way of thinking about it. Silly me! Thanks for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|