The hand cursor is shown automatically if RepositoryItemHyperLinkEdit or RepositoryItemHypertextLabel is assigned to a grid column.
To change the current cursor for an arbitrary cell, handle the GridView's MouseMove and MouseLeave events. Within the MouseMove event handler you need to determine whether the mouse pointer is over your cell or not and whether your additional conditions are satisfied. You can use Hit Information to check what visual element is located under Cursor. Then set the GridControl's Cursor property to the System.Windows.Forms.Cursors.Hand value if all conditions are satisfied and restore the cursor back to the default value otherwise.
C#private void GridView1_MouseLeave(object sender, EventArgs e) {
GridView view = sender as GridView;
view.GridControl.Cursor = System.Windows.Forms.Cursors.Default;
}
private void GridView1_MouseMove(object sender, MouseEventArgs e) {
GridView view = sender as GridView;
GridHitInfo hi = view.CalcHitInfo(new Point(e.X, e.Y));
if (hi.InRowCell & YourOtherConditionsAreSatisfied(hi))
view.GridControl.Cursor = System.Windows.Forms.Cursors.Hand;
else
view.GridControl.Cursor = System.Windows.Forms.Cursors.Default;
}
bool YourOtherConditionsAreSatisfied(GridHitInfo hi) {
bool result = true;
// your conditions here
return result;
}
In the attachment, you will find a sample project which demonstrates this approach.
Also, you may want to check our quick-reference guide - it contains cheat sheets, best practices, and troubleshooting sections:
DevExpress WinForms Cheat Sheets
If this is the 'Designed Effect', you should rethink your design.
Hyperlink's by default change the mouse cursor to a hand.
Do a poll of your customers, I'll bet two thirds or more vote to change the cursor.
Hi,
Now, the hand cursor is shown automatically if RepositoryItemHyperLinkEdit or RepositoryItemHypertextLabel is assigned to a grid column. Since this article is quite old, I have updated it accordingly.
What if the column has "readonly = true" and "allowedit = false"
Then the cursor does not change to hand even when it has a repository item HyperTextLabel.
How to do that ?
(Winforms Gridview 18.1.14)
Hello,
You can handle the GridView's MouseMove and MouseLeave events. Within the MouseMove event handler you need to determine whether the mouse pointer is over your cell or not and whether your additional conditions are satisfied. You can use Hit Information to check what visual element is located under Cursor. Then set the GridControl's Cursor property to the System.Windows.Forms.Cursors.Hand value if all conditions are satisfied and restore the cursor back to the default value otherwise.
private void GridView1_MouseLeave(object sender, EventArgs e) { GridView view = sender as GridView; view.GridControl.Cursor = System.Windows.Forms.Cursors.Default; } private void GridView1_MouseMove(object sender, MouseEventArgs e) { GridView view = sender as GridView; GridHitInfo hi = view.CalcHitInfo(new Point(e.X, e.Y)); if (hi.InRowCell & YourOtherConditionsAreSatisfied(hi)) view.GridControl.Cursor = System.Windows.Forms.Cursors.Hand; else view.GridControl.Cursor = System.Windows.Forms.Cursors.Default; } bool YourOtherConditionsAreSatisfied(GridHitInfo hi) { bool result = true; // your conditions here return result; }
In the attachment, you will find a sample project which demonstrates this approach.