在VB.NET中单击它时,如何取消选择所选的DataGridViewRow? [英] How can I deselect a selected DataGridViewRow when clicking it in VB.NET?

查看:255
本文介绍了在VB.NET中单击它时,如何取消选择所选的DataGridViewRow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击它时,我正在寻找一种方法来取消选择所选的DataGridViewRow。我已经尝试使用DataGridView类的各种单击事件,但问题是SelectionChanged在这些之前被触发,当用户单击未选择的行时,会导致明显的意外行为。



如何获取我想要的行为者?

解决方案

这听起来像是尝试alter标准的窗口选择多个对象行为。即,允许多选,然后通过单击要取消选择的所选行来取消选择给定行。由于datagrid将会根据标准的事件处理方式对您的牙齿和钉子进行攻击,因此可以处理点击事件,并使用鼠标事件来确定点击的位置等等,但是这是凌乱而脆弱的。 / p>

我建议您向用户推荐标准窗口选择行为,或者添加包含复选框的选定列,并解释 进一步处理复选框值列表中的真实性


I'm looking for a way to deselect a selected DataGridViewRow when the user clicks on it. I have tried fiddling with the various click events of the DataGridView class, but the problem is that the SelectionChanged is fired before these, which causes obvious unintended behavior when the user is clicking a row not selected.

How can I obtain the behvior I want?

解决方案

It sounds like you are try the alter standard windows select multiple object behaviour. I.e., allowing multi-select then deselecting a given row by clicking on the selected row that you want to deselect. Since the datagrid will fight you tooth and nail in trying to do this based on the standard event handling, you could handle the click event, and use mouse events to determine where they click, etc ... but this is messy and fragile.

I would recommend either teaching standard windows selection behaviour to your users or adding a "selected" column that contains a checkbox and interpreting the "truthiness" of the checkbox value column in further processing.

这篇关于在VB.NET中单击它时,如何取消选择所选的DataGridViewRow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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