Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to cancel rowselection datagridview

Status
Not open for further replies.

ErnstJan

Programmer
Nov 10, 2002
114
0
0
NL
Hi,

Probably a basic thing but how can you cancel the row selection in a datagridview?
Used google but probably used the wrong words because I was unable to find the answer I am looking for.

What I want to do is when user selects a row it first needs to check if there are unsaved data in the form.
If this fails it should return to the previous row.

Tried doing this in selectionchanged but I can't cancel the selection of the selected row.

Can someone please give me some code to hanles this.

Thank very much in advance.

Ernst Jan
 
did you try:

datagridview.ClearSelection()

--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
 
I did but that is not working.
With that command you clear any selection.
So no row would be selected after that.

I want the selection to return to the previous row.
 
Oke solved my problem. Atleast for now. :)
I had my code in Datagridview.SelectionChanged event.
Now I moved is to the MouseClick event.
So far it seems to be working.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top