datagridview multiselect但仅在1行上 [英] datagridview multiselect but on 1 row only
本文介绍了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设计,请参见 ^ ].
这是一种富有成效的方法.假设您有一些基于选择的命令,并且假设它们在菜单,上下文菜单,主菜单或两者中.如果不是这样,您可以轻松地将我的想法适应您的设计,首先尝试理解它.现在,允许用户进行多选.提供一些情况下对任意单元格子集都有效的命令.另外,提供一些其他命令,这些命令在用户的选择很特殊时才有效,也就是说,要符合您刚刚描述的约束:任何带有单个原始字符的选择.根据选择启用或禁用这些其他命令,但始终在菜单中显示它们.这样,用户会知道还有一些其他命令,但是她或他需要做一些事情来启用它们.由于很可能只选择一个单元格(不按住Ctrl),因此用户最终将看到启用了附加命令.通过正确命名菜单项以及诸如工具提示或状态栏提示之类的信息,为用户提供有关特殊选择(同一行中选定单元格的任意子集)的值的其他线索:选择诸如 this 进行那个".菜单项的正确命名应被视为提供线索,工具提示或状态栏提示的主要手段-次要提示.
这个想法怎么样?您可以想到别的东西.首先,您想要的东西应该更好.
—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.
SuchDataGridViewSelectionMode
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屋!
查看全文