如何解决datagridview单击事件和拖放togeder不起作用-WinForm
通过执行以下示例,我已经在DataGridView
的行之间实现了这种简单的拖放操作:
datagridview-drag-and-drop-rows
该网格具有一个复选框列(DataGridViewCheckBoxColumn
),该列在实现拖放后不再可单击。
也许事件MouseMove
和MouseDown
绕过了复选框的点击,所以我试图拦截鼠标的位置并获得对基础控件(复选框)的引用并以编程方式对其进行检查,但没有成功。
private void dataGridView1_MouseDown(object sender,MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Control dgrid = sender as Control;
Point now = dgrid.PointToClient(Cursor.Position);
foreach (DataGridViewCheckBoxCell c in dgrid.Controls.OfType<DataGridViewCheckBoxCell>())
{
//check if the point is inside the area
}
...other drag&drop operations
}
但是dgrid.Controls.OfType<DataGridViewCheckBoxCell>()
似乎没有任何单元格(显然有很多)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。