Solved

DataGridView Multi Row Select with Mouse click

Posted on 2008-06-23
5
4,276 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
  • 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

825 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