Datagrid row-specific tooltips

J

JezB

Anyone know how to get a tooltip on each row of a datagrid ? The tooltip
text must be configured depending on the row that the mouse is hovering
over, and the hover timer must be reset when the user is moving the mouse
over the rows of the grid (but not necessarily moving off the grid).

No matter what I try I cannot get this to work ! Not using the grid's
tooltip property anyway, but perhaps there is a better way.
 
O

otabekhm

Hi,
I never dealed with tooltip, but I think you have to find row in
mouseHover event handler by hittest:
private void dataGrid_hover(object sender,
System.Windows.Forms.MouseEventArgs e)
{
DataGrid dataGrid = (DataGrid)sender;
Point hitPoint = new Point(e.X,e.Y);
int rowIndex = dataGrid.HitTest(hitPoint).Row;
//... change tooltip
text here depending on rowIndex
// then reset mouse
event args to be able to raise hover event again
}
to reset mouse event args you have to inherit from datagrid and call
base.ResetMouseEventArgs();
Hope it will be helpful,

Otabek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top