Spread Windows Forms 6.0 Product Documentation
Customizing the Display of the Cursor
Support Options
Spread Windows Forms 6.0 Product Documentation > Developer's Guide > Customizing the Sheet Appearance > Customizing the Appearance of the Overall Component > Customizing the Display of the Cursor

Glossary Item Box

You can set the cursor or pointer to appear differently for different parts of the display. To determine the cursor display, use the GetCursor method and SetCursor method and the CursorType enumeration. The code for setting the cursor to change when it is over a header cell, as shown in this figure, is given in the example below.

Hand cursor over header cells

The Spread component uses one cursor for locked cells (CursorType enumeration equal to Locked) and one cursor for unlocked cells (CursorType enumeration equal to Normal). The component does not support different cursors for each cell type.

Return to Customizing the Overall Component Appearance.

Cell Types and Reserved Locations

The built-in hyperlink cell type by default uses the hand cursor over the link area. For more information, refer to Setting a Hyperlink Cell.

Some cell types (for example, button, check box, combo box, and hyperlink) reserve areas within the cell that require special mouse processing. For example, clicking a mouse button while over the drop-down button in a combo box cell immediately enters edit mode. The location of the special area and the cursor used over the special area is determined by the IsReservedLocation and GetReservedCursor methods in the cell type classes. If you do not like the cursor supplied by a built-in cell type class then you could derive a class from the built-in cell type class and override the GetReservedCursor method.

The GetReservedCursor method is only called for locations where IsReservedLocation returns non-null. By returning null (Nothing in VB) or non-null, the IsReservedLocation method essentially divides the cell rectangle into two subregions (normal region and reserved region). In the normal subregion, a mouse down is processed by the spread and starts a cell selection. Since the mouse down is processed by the Spread component, the mouse cursor is determined by the Spread component (that is, GetReservedCursor is not called). In the reserved subregion, a mouse down immediately starts a cell edit and the mouse down gets passed to the cell editor for processing. Since the mouse down is processed by the cell editor, the mouse cursor is determined by the cell type via the GetReservedCursor method. While you can supply cell type specific cursors for the reserved subregion, you can not supply cell type specific cursors for the normal subregions.

Example

This example sets the cursor to display as a hand as shown in the figure above.

C# Copy Code
private void Form1_Load(object sender, System.EventArgs e){
 
  
 
 // Change the cursor shape on column headers.
 
 fpSpread1.SetCursor(FarPoint.Win.Spread.CursorType.ColumnHeader, System.Windows.Forms.Cursors.Hand);
 
  
 
 }
 
VB Copy Code
 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
  
 
 ' Change the cursor shape on column headers.
 
 FpSpread1.SetCursor(FarPoint.Win.Spread.CursorType.ColumnHeader, System.Windows.Forms.Cursors.Hand)
 
  
 
 End Sub
 

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.