自定义DataGridViewButton单击 [英] Custom DataGridViewButton Click
本文介绍了自定义DataGridViewButton单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
美好的一天所有!!!
我有DataGridView,我正在为某些单元格绘制自定义按钮。
附件点击事件工作正常。
但我遇到的问题是,当我滚动DataGridView然后尝试单击按钮时,它会触发所有按钮点击事件我点击的行上方的行,一旦获得我实际点击的行,就会停止。
Good day all!!!
I have DataGridView that I''m drawing custom buttons to some cells.
The attached click event works fine.
But the problem I''m having is that when I scroll the DataGridView then try and click the button it fires the button click events for all the rows above the row that I clicked and stops once it gets the the row that I actually clicked.
推荐答案
通过使用HitTestInfo首先检查行来解决问题。
Solved the problem by using HitTestInfo to first check the row.
public bool IsMouseInButtonBoundary(Point point)
{
DataGridView.HitTestInfo ht = m_GridView.HitTest(point.X, point.Y);
if (ht.RowIndex == RowIndex)
{
if (point.X >= X && point.X <= Right)
{
if (point.Y >= Y && point.Y <= Bottom)
{
return true;
}
}
}
return false;
}
这篇关于自定义DataGridViewButton单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文