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.
Unfortunately, activation email could not send to your email. Please try again.

How do you change the cursor for each header cell?

Thread ID:

Created:

Updated:

Platform:

Replies:

14679 Jun 2,2004 06:27 AM Jun 2,2004 10:08 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 2, 2004 06:27 AM

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?

Administrator [Syncfusion]
Replied On June 2, 2004 09:00 AM

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.

Administrator [Syncfusion]
Replied On June 2, 2004 09:40 AM

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. >

Administrator [Syncfusion]
Replied On June 2, 2004 10:08 AM

>>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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;