0

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?

3
  • What type is the control you're working on? Some controls are designed to have "multi-select" functinality w/o much effort. Jun 30, 2009 at 15:02
  • I'm not terribly familiar with the C# terminology yet, so I'm not sure which part of this table display is a control (or if the display is itself a control). The class definition is public class SearchList : Control which I'm guessing means I'm either extending Control or implementing the control interface. Does that help at least provide you with information to give me the direction I need to find the actual answer to your question?
    – Kivus
    Jun 30, 2009 at 15:07
  • Based on the answers provided I was able to more fully explore implementing the multi-select functoinality. That was the initial purpose of this question and therefore, I have marked it as answered.
    – Kivus
    Jun 30, 2009 at 16:49

2 Answers 2

2

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.

2
  • 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
    Jun 30, 2009 at 16:07
  • Pop open a new project, throw in a ListView control, then set the "View" property to "Details". Jun 30, 2009 at 16:28
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.