Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView - Cursor Change on MouseHover

Status
Not open for further replies.

eb24

Programmer
Dec 17, 2003
240
US
I am trying to recognize when the Cursor is over the Header. I have tried the following but it seems to change cursor anywhere within the DataGridView. Thanks for any help!
Code:
private void DataGridView1_MouseHover(object sender, EventArgs e) 
{
   if (DataGridView1.CurrentRow.Index == 0) 
   {
       DataGridView1.Cursor = Cursors.Hand; 
   }
}
 
i'm not a desktop developer, but i would try this: get reference to header, then define the mousehover event on the header.
Code:
datagridviewrow header = mydatagridview.HeaderRow;
if(header != null)
{
   header.mousehover += new eventhandler(header_MouseHover);
}

private void header_MouseHover(object sender, EventArgs e) 
{
   datagridviewrow row = (datagridviewrow)sender;
   if (row.Index == 0) 
   {
       row.Cursor = Cursors.Hand; 
   }
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top