Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
hi guys,

so i want the user to be able to select multiple rows. i've done this by setting multiselect = true and selectionmode = cellselect.. the problem is the selections spans multiple rows.. i want the user to only be able to select on the row where he/she first mousedown..

any suggestions?
Posted
Comments
Sergey Alexandrovich Kryukov 5-Oct-11 13:53pm    
The question is interesting enough, I voted 5 for it.
--SA

1 solution

It sounds like you want multi-select and single-select at the same time :-). Not so, of course: what you want is clear: to have arbitrary cell selection within the single row.

Such DataGridViewSelectionMode option does not exists, and I think, for a good reason: the users expect something more usual. So, not only I don't see the exact solution for what you want, I recommend you not to seek such solution. Instead, my best suggestion would be: give up this requirement and review your UI design the way it would use one of the usual and well-expected selection modes, see http://msdn.microsoft.com/en-us/library/8x6w9028.aspx[^].

Here is one fruitful approach. Suppose you have some commands based on selection and suppose they are on the menu, context menu, main menu or both. If this is not so, you can easily adjust my idea to your design, first try to understand it. Now, allow the user do multi-selection. Provide some commands for the case valid for any arbitrary subset of cells. Additionally, provide some additional commands valid when user's selection is special, that is, conforming to the constraint you just describe: any selection withing the single raw. Make these additional commands enabled or disables depending on selection, but always show them in the menu. This way, the user will have a clue that there are some additional commands but she or he needs to do something to enable them. As selection of just one cell is most likely (no holding of Ctrl), the user will eventually see the additional command enabled. Give the user additional clue about the value of your special selection (arbitrary subset of selected cells in the same row) by proper naming of the menu items and something like a tooltip or a status bar hint: "select cells like this to do that". Proper naming of the menu items should be considered as a main mean to give the clue, a tooltip or a status bar hint — a secondary one.

How about this idea? You can think of something else. It should be something better that what you wanted in first place.

—SA
 
Share this answer
 
v2
Comments
markypm 5-Oct-11 13:44pm    
unfortunately, the context of the application requires the said functionality. regardless, the link you gave me contained the answer i needed so thanks nevertheless! +5
Sergey Alexandrovich Kryukov 5-Oct-11 13:46pm    
I understand. Please see my update. You cannot make a miracle but you can provide reasonable functionality and good usability.
If nevertheless some other selection mode is better for you -- good for you, just use it.

If you agree that it makes sense, please also formally accept the answer (green button).
--SA
Espen Harlinn 5-Oct-11 15:23pm    
5'ed!
Sergey Alexandrovich Kryukov 5-Oct-11 15:52pm    
Thank you, Espen.
A bit of tricky case, isn't it?
--SA
VB Prog 5-Oct-11 16:32pm    
Which Selectionmode did you have to use?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900