Solved

DataGridView Multi Row Select with Mouse click

Posted on 2008-06-23
5
4,295 Views
Last Modified: 2013-12-16
I want to be able to select/deselect multiple rows in a databound DataGridView with a mouse click without having to use the Control key.  I thus have to disable the deselect row event when I click on a new row.  Also I want to be able to deselect already selected rows also with a mouse click.

If possible I want to do this without overriding the existing mouse click events in the DataGridView class.
0
Comment
Question by:pvrooyen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:topdog770
ID: 21846294
With all respect, the three things you have listed seem to be... odd and perhaps a bit contradictory sounding as I was reading them.

What is your motivation for wanting to ignore the built in data grid view events?

You want to select multiple rows using just a mouseclick, but then want to deselect multiple rows with just a mouse click and don't want to use the datagridview mouse events.

Regarding the mouse click events, if there really is an excellent reason for not using the datagridviews mouse events, you could handle the mouse events at the parent control level using WndProc.

I suppose you could also set up the selection process to start by 'auto selecting' rows when the mouse is clicked while over a row, and use a timer that says if it's been more then a second since the user selected a row, change to deselect mode.

0
 
LVL 3

Expert Comment

by:pragmatistMS
ID: 21848131
I would agree with above poster.  Ctrl-Click for multiple select is a standard UI convention, my recommendation would be to not circumvent these conventions.  Sometimes users ask for bizarre things they believe will make their job easier, when in reality the confusion it creates makes their lives more difficult.
0
 

Author Comment

by:pvrooyen
ID: 21853429
I do not agree.  The user needs to make heavy intensive and repetitive use of selecting and deselecting rows constantly on a daily basis.  To implement that selecting/deselecting functionality without the use of a Control pressed key all the time have huge advantages in the long run.

>>You want to select multiple rows using just a mouseclick, but then want to deselect multiple rows >>with just a mouse click and don't want to use the datagridview mouse events.

Yes exactly, why does this request seem so strange?  I want a Control key depressed select/deselect functionality without pressing the Control key.

>>I suppose you could also set up the selection process to start by 'auto selecting' rows when the >>mouse is clicked while over a row, and use a timer that says if it's been more then a second since >>the user selected a row, change to deselect mode.

I would rather: OnMouseDownEvent: Select row if deselected OR Deselect row if selected.

Thanks.
0
 
LVL 3

Accepted Solution

by:
pragmatistMS earned 500 total points
ID: 21855204
I do understand sometimes the need for specialized UI features at times.  What you want to accomplish is typically done with check boxes to the left of the row or some other convention, which would be my next suggestion.  Otherwise I will just bow out of the thread now so that others can respond.
0
 

Author Closing Comment

by:pvrooyen
ID: 31469673
Although there is a good reason for me to use full highligted rows as selected indicators I have awarded the points because at least you were offering an alternative.  It thus seems there are no easy way to do this.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question