We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How do you change the cursor for each header cell?

I have a situation where not all headers (or columns) in the grid are sortable, yet by default all of the grid''s header cells show the sort cursor when you mouse into them. How can I easily disable this programatically so I can turn on (or off) the cursor depending on whether the column is sortable?

3 Replies

AD Administrator Syncfusion Team June 2, 2004 01:00 PM UTC

By default, the grid does not display any special cursor when you are over a sortable column header. It just displays the default pointer cursor. If you want to prevent the sorting for a particular column, then you can handle the CellClic event (or CellDoubleClick event) and set e.Cancel = true if the click is on a column header you do not want to sort.
private void gridDataBoundGrid1_CellClick(object sender, GridCellClickEventArgs e)
{
        //don''t sort col 2
	if(e.RowIndex == 0 && e.ColIndex == 2)
	{
		e.Cancel = true;
	}
}
Now if you want to display a special cursor, you can do so by deriving the grid and overriding OnSetCursor. Here is a sample. You can add additional checks to narrow where you set the cursor.


AD Administrator Syncfusion Team June 2, 2004 01:40 PM UTC

Well by default it is setting the cursor for my header cells to a sorting cursor (a down arrow in black). I haven''t done anything special to make it do this, so how do I disable this? >By default, the grid does not display any special cursor when you are over a sortable column header. It just displays the default pointer cursor. > >If you want to prevent the sorting for a particular column, then you can handle the CellClic event (or CellDoubleClick event) and set e.Cancel = true if the click is on a column header you do not want to sort. > >
>private void gridDataBoundGrid1_CellClick(object sender, GridCellClickEventArgs e)
>{
>        //don''t sort col 2
>	if(e.RowIndex == 0 && e.ColIndex == 2)
>	{
>		e.Cancel = true;
>	}
>}
>
> >Now if you want to display a special cursor, you can do so by deriving the grid and overriding OnSetCursor. Here is a sample. You can add additional checks to narrow where you set the cursor. >


AD Administrator Syncfusion Team June 2, 2004 02:08 PM UTC

>>Well by default it is setting the cursor for my header cells to a sorting cursor (a down arrow in black). That is the column selections cursor that you get when you mouse down on a column header to indicate that you can select columns by dragging the mouse at this point of time. (It does not have anything to do with sorting, and whether or not this cursor is visible will have no effect on sorting.) You can turn this off by removing the Columns flag from the grid.AllowSelections property.

Loader.
Live Chat Icon For mobile
Up arrow icon