Solved

DataGridView Multi Row Select with Mouse click

Posted on 2008-06-23
5
4,257 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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now