views:

512

answers:

2

I'm working on a piece of code that I inherited and am trying to expand it from only being able to select one row to being able to select multiple rows.

Essentially, the item I'm working with displays like a data table. It contains methods for "OnSelectItem" and "OnMouseDown", with "OnMouseDown" checking to see if the click is right mouse button click or a left mouse button click.

Generally, how is functionality to support the ability to support Multi Select implemented? Is it handled through recognization of the mouse clicks in addition to holding down particular keys or is there a different way to implement this type of functionality?

+2  A: 

Your comments indicate that you're working with a custom control. So, answers that apply to general Microsoft-supplied controls may not work at all.

You should be able to use the events you've listed already to handle multi-select features in this custom control.

As an example, you could look at the CheckedListBox control. It has a checkbox in front of every row. If the box is checked, that row is "selected". If that's not the type of selection you're looking for, then you can look at the ListView control in Detail mode. It allows you to set options that let the user highlight multiple rows, using CTRL and/or SHIFT to modify the way the mouse-click affects selection.

John Fisher
Okay. I've figured out how to recognize when I'm holding the the CTRL key and making an item selection. I can walk down this path a little more.Your suggestion about "[looking] at the ListView control in Detail Mode" sounds like it might have some merit. I don't know exactly what you mean by it though. I'm not even sure what "Detail Mode" is, unfortunately. Still too new to the C# / Visual Studio world.
Kivus
Pop open a new project, throw in a ListView control, then set the "View" property to "Details".
John Fisher
Cool. Thanks for the tip.
Kivus
A: 

As far as multi select is concerned from my point of view it also requires key board support in addition to mouse click

1) In Controls if we press shift key and then press up or down arrow key then also row get selected

2) We can also implement multi select functionality by checkbox column, i am not sure this is possible or not in your case

3) There is also fundamental of Fixed Column, on mouse click of that column entire row is getting selectd

Harryboy