Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example locks a cell, displays a customized icon for the pointer when over the locked cell, and displays an arrow pointer over the column headers.

To access the file used in this sample, change the path in the code to the path for your product installation's \SAMPLES\FILES directory.

C++

// Define variables
PIC picture;
HICON hIcon;
// Lock a cell
// Specify the cell
m_Spread.SetCol(3);
m_Spread.SetRow(2);
// Mark the cell as locked
m_Spread.SetLock(TRUE);
// Prevent the user from editing the cell
m_Spread.SetProtect(TRUE);

// Set the pointer to display an icon when over the locked cell
// Define the icon
// Convert hIcon
CPictureHolder picture;
HICON hIcon = AfxGetApp()->LoadIcon(IDI_HAND_LEFT);
picture.CreateFromIcon(hIcon);
m_Spread.SetCursonIcon(picture.GetPictureDispatch());
// Specify the locked cell
m_Spread.SetCursorType(CursorTypeLockedCell);
// Set the pointer to use the icon specified in the CursorIcon property
m_Spread.SetCursorStyle(CursorStyleUserDefined);

// Set the row height for the row with the locked cell
m_Spread.SetRowHeight(2,20);
// Set the column width for the column with the locked cell
m_Spread.SetColWidth(3,10);

// Set the pointer to display an arrow when over the column headers
// Specify the column headers
m_Spread.SetCursorType(CursorTypeColHeader);
// Define the pointer style
m_Spread.SetCursorStyle(CursorStyleArrow);

Visual Basic

' Lock a cell
' Specify the cell
fpSpread1.Col = 3
fpSpread1.Row = 2
' Mark the cell as locked
fpSpread1.Lock = True

' Prevent the user from editing the cell
fpSpread1.Protect = True

' Set the pointer to display an icon when over the locked cell
' Define the icon
fpSpread1.CursorIcon = LoadPicture ("C:\Samples\Files\secur02b.ico")
' Specify the locked cell
fpSpread1.CursorType = CursorTypeLockedCell
' Set the pointer to use the icon specified by the CursorIcon property
fpSpread1.CursorStyle = CursorStyleUserDefined

' Set the row height for the row with the locked cell
fpSpread1.RowHeight(2) = 20
' Set the column width for the column with the locked cell
fpSpread1.ColWidth(3) = 10

' Set the pointer to display an arrow when over the column headers
' Specify the column headers
fpSpread1.CursorType = CursorTypeColHeader
' Define the pointer style
fpSpread1.CursorStyle = CursorStyleArrow

Copyright © GrapeCity, inc. All rights reserved.