Click here to Skip to main content
15,883,623 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
I have DataGridView(dgv) like this
No name Edit(Link column)
1   A   Edit
2   B   Edit
3   C   Edit

I want display Wait cursor if it is on Edit cell where No=2
and Hand cursor for reaining records.
thanks in advance
Posted
Updated 21-May-17 19:51pm
v2
Comments
Shemeemsha (ഷെമീംഷ) 22-Sep-14 10:03am    
Why you are not using css for it?

 
Share this answer
 
Comments
Ravi Sargam 7-Apr-12 4:19am    
it's not working is there any other way
The CellMouseEnter event of DataGridView control can be used for this purpose as shown below
C#
private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e) 
{
    //Skip the Column and Row headers
    if (e.ColumnIndex < 0 || e.RowIndex < 0) {
        return;
    }
    var dataGridView = (sender as DataGridView);
    //Check the condition as per the requirement casting the cell value to the appropriate type
    if (e.ColumnIndex == 2 && (string)dataGridView.Rows[e.RowIndex].Cells[0].Value=="2")
        dataGridView.Cursor = Cursors.WaitCursor;
    else
        dataGridView.Cursor = Cursors.Hand;
}
 
Share this answer
 
Comments
Member 14028150 22-Oct-18 8:01am    
once moved from first row to header the cursor will not change to default
C#
private void YourDataGrideView_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (YourDataGrideView.Columns[e.ColumnIndex]=='your col index')
            {
                YourDataGrideView.Cursor = Cursors.Hand;
            }
            else
                YourDataGrideView.Cursor = Cursors.Default;
        }

        private void YourDataGrideView_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
        {
            YourDataGrideView.Cursor = Cursors.Default ;
        }
 
Share this answer
 
v2

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