Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

Solved the problem by using HitTestInfo to first check the row.


C#
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;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900