Visual Basic (Declaration) | |
---|---|
Function IsReservedLocation( _ ByVal g As Graphics, _ ByVal x As Integer, _ ByVal y As Integer, _ ByVal rc As Rectangle, _ ByVal appearance As Appearance, _ ByVal value As Object, _ ByVal zoomFactor As Single _ ) As Object |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As IEditor Dim g As Graphics Dim x As Integer Dim y As Integer Dim rc As Rectangle Dim appearance As Appearance Dim value As Object Dim zoomFactor As Single Dim value As Object value = instance.IsReservedLocation(g, x, y, rc, appearance, value, zoomFactor) |
C# | |
---|---|
object IsReservedLocation( Graphics g, int x, int y, Rectangle rc, Appearance appearance, object value, float zoomFactor ) |
Parameters
- g
- Graphics device interface for painting the editor control
- x
- X-coordinate of pointer location
- y
- Y-coordinate of pointer location
- rc
- Location and size of a rectangular region
- appearance
- Appearance settings of the editor control
- value
- Object containing the name of the editor control
- zoomFactor
- Numeric value for scaling the display of the editor control
Return Value
Non-null if the location is a reserved cell area; null (Nothing in VisualBasic) if the location is in a normal cell areaIf this method returns null (Nothing in VisualBasic) then the location is in a normal cell area (that is, a single click selects a cell and double-click edits the cell). If this method returns non-null then the location is in a special cell area (that is, single click edits the cell). Examples of special cell areas include a drop-down button in a combo box cell, a knob in a slider cell, increment buttons, and the entire area in a button or check box cell. During MouseMove events, non-null values from IsReservedLocation get passed to GetReservedCursor to obtain the mouse pointer to display over the special area. This allows for the possibility of multiple special areas with each special area having its own cursor. The non-null object can be anything the cell type has. The Spread component only checks for null or nun-null. If the cell type has multiple special areas, then the cell type might return an integer or enumeration value to indicate which special area the mouse is over. If the cell type only has one special area, then the cell type could simply return itself as the non-null object.
class CheckBoxCellType : BaseCellType
{
...
public override object IsReservedLocation(...)
{
return this;
}
public override Cursor GetReservedCursor(object o)
{
if (o != null)
return Cursors.Arrow;
else
return null;
}
...
}
Note: The IsReservedLocation and GetReservedCursor methods work as a team with the one getting called after the other.
For limits on the zoomFactor parameter, refer to the ZoomFactor property for the sheet.
C# | Copy Code |
---|---|
public static CheckBox ck = new CheckBox(); class myEditor : FarPoint.Win.Spread.CellType.IEditor { public event EventHandler EditingCanceled; public event EventHandler EditingStopped; public bool StopEditing() { if (EditingStopped != null) { EditingStopped(ck, EventArgs.Empty); base.FireEditingStopped(); return true; } else { return false; } } public void CancelEditing() { EditingCanceled(ck, EventArgs.Empty); base.FireEditingCanceled(); } public bool IsReservedKey(KeyEventArgs e) { return false; } public bool IsValid(Object value) { return true; } public Size GetPreferredSize(System.Windows.Forms.Control editor) { return editor.Size; } public Cursor GetReservedCursor(object o) { return null; } public Control GetEditorControl(FarPoint.Win.Spread.Appearance appr, float zoom) { return ck; } public object GetEditorValue() { return ck.CheckState; } public void SetEditorValue(object value) { } public object IsReservedLocation(Graphics g, int x, int y, Rectangle r, FarPoint.Win.Spread.Appearance appr, object value, float zoom) { return null; } public void StartEditing(EventArgs e, bool selectAll) { selectAll = true; } public void ShowSubEditor() { this.ShowSubEditor(); } } private void Form1_Load(object sender, System.EventArgs e) { fpSpread1.ActiveSheet.Cells[0, 0].Editor = new myEditor(); } |
Visual Basic | Copy Code |
---|---|
Shared ck As New CheckBox() Public Class myEditor Implements FarPoint.Win.Spread.CellType.IEditor Public Event EditingStopped(ByVal sender As Object, ByVal e As EventArgs) Implements FarPoint.Win.Spread.CellType.IEditor.EditingStopped Public Event EditingCancelled(ByVal sender As Object, ByVal e As EventArgs) Implements FarPoint.Win.Spread.CellType.IEditor.EditingCanceled Public Function StopEditing() As Boolean Implements FarPoint.Win.Spread.CellType.IEditor.StopEditing RaiseEvent EditingStopped(ck, EventArgs.Empty) MyBase.FireEditingStopped() Return True End Function Public Sub CancelEditing() Implements FarPoint.Win.Spread.CellType.IEditor.CancelEditing RaiseEvent EditingCancelled(ck, EventArgs.Empty) MyBase.FireEditingCanceled() End Sub Public Function IsReservedKey(ByVal e As KeyEventArgs) As Boolean Implements FarPoint.Win.Spread.CellType.IEditor.IsReservedKey Return False End Function Public Function IsValid(ByVal value As Object) As Boolean Implements FarPoint.Win.Spread.CellType.IEditor.IsValid Return True End Function Public Function GetReservedCursor(ByVal o As Object) As Cursor Implements FarPoint.Win.Spread.CellType.IEditor.GetReservedCursor Return Nothing End Function Public Function GetEditorControl(ByVal appr As FarPoint.Win.Spread.Appearance, ByVal zoom As Single) As Control Implements FarPoint.Win.Spread.CellType.IEditor.GetEditorControl Return ck End Function Public Function GetEditorValue() As Object Implements FarPoint.Win.Spread.CellType.IEditor.GetEditorValue Return ck.CheckState End Function Public Function GetPreferredSize(ByVal editor As System.Windows.Forms.Control) As Size Implements FarPoint.Win.Spread.CellType.IEditor.GetPreferredSize Return editor.Size End Function Public Sub SetEditorValue(ByVal value As Object) Implements FarPoint.Win.Spread.CellType.IEditor.SetEditorValue ck.CheckState = CheckState.Checked End Sub Public Function IsReservedLocation(ByVal g As Graphics, ByVal x As Integer, ByVal y As Integer, ByVal r As Rectangle, ByVal appr As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal zoom As Single) As Object Implements FarPoint.Win.Spread.CellType.IEditor.IsReservedLocation Return Nothing End Function Public Sub StartEditing(ByVal e As EventArgs, ByVal selectAll As Boolean) Implements FarPoint.Win.Spread.CellType.IEditor.StartEditing selectAll = True End Sub Public Sub ShowSubEditor() Implements FarPoint.Win.Spread.CellType.IEditor.ShowSubEditor Me.ShowSubEditor() End Sub End Class Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load FpSpread1.ActiveSheet.Cells(0, 0).Editor = New myEditor() End Sub |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2