datagridview multiselect但仅在1行上 [英] datagridview multiselect but on 1 row only

查看:139
本文介绍了datagridview multiselect但仅在1行上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

所以我希望用户能够选择多行.我通过设置multiselect = true和selectionmode = cellselect来完成此操作.问题是选择跨越多行..我希望用户只能在他/她第一次将鼠标按下的行上进行选择. />
有任何建议吗?

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?

推荐答案

听起来您想要同时进行多选和单选:-).当然不是这样:您想要的很清楚:在单行中具有任意单元格选择.

这样的DataGridViewSelectionMode选项不存在,我认为这是有充分理由的:用户期望使用更常用的东西.因此,不仅我没有找到您想要的确切解决方案,而且我建议您不要寻求这样的解决方案.相反,我最好的建议是:放弃此要求,并以一种通常使用且期望良好的选择模式来检查您的UI设计,请参见
这个想法怎么样?您可以想到别的东西.首先,您想要的东西应该更好.

—SA
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


这篇关于datagridview multiselect但仅在1行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆