Spread for ASP.NET 8.0 Product Documentation
Format Method (CheckBoxCellType)
Example 


Object in the data model from which to get formatting information
When deriving a cell type based on this type, override this to change what gets passed back and formatted as a string into the cell on the sheet from the object in the data model.
Syntax
'Declaration
 
Public Overrides Function Format( _
   ByVal o As Object _
) As String
'Usage
 
Dim instance As CheckBoxCellType
Dim o As Object
Dim value As String
 
value = instance.Format(o)
public override string Format( 
   object o
)

Parameters

o
Object in the data model from which to get formatting information

Return Value

Formatted string to put in the cell on the sheet
Example
The following example subclasses the CheckBoxCellType class and creates a check box cell in the first cell of the spreadsheet. Its checked and unchecked images are set in the constructor and it uses the values of 0 or 1 for the check box state.
[Serializable()]
class myCheck:FarPoint.Web.Spread.CheckBoxCellType
{
public myCheck(string img1,string img2)
{
Base.CheckedImageUrl=img1;
Base.UncheckedImageUrl=img2;
}

public override string Format(object o)
{
return Base.Format(o);
}

public override Control GetEditorControl(string id,TableCell tc,FarPoint.Web.Spread.Appearance style,FarPoint.Web.Spread.Inset margin,object v,bool ul)
{
return Base.GetEditorControl(id,tc,style,margin,v,ul);
}

public override object GetEditorValue(Control owner,string id)
{
return Base.GetEditorValue(owner,id);
}

public override Control PaintCell(string id,TableCell tc,FarPoint.Web.Spread.Appearance style,FarPoint.Web.Spread.Inset margin,object v,bool ul)
{
return Base.PaintCell(id,tc,style,margin,v,ul);
}

public override object Parse(string s)
{
return Base.Parse(s);
}

public override bool ValidateEditorValue(object val,out string reason)
{
return Base.ValidateEditorValue(val,out reason);
}

new public bool BooleanValue
{
Get
{
return Base.BooleanValue;
}
Set
{
Base.BooleanValue=value;
}
}

public override string EditorClientScriptUrl{Get{Return"checkboxeditor.htc";}}

public override string RendererClientScriptUrl{Get{Return"checkboxrender.htc";}}

}

private void Page_Load(object sender,System.EventArgs e)
{
myCheckckbox= new myCheck("img/checked.gif","img/unchecked.gif");
ckbox.BooleanValue=False;
FpSpread1.ActiveSheetView.Cells[0,0].CellType=ckbox;
FpSpread1.ActiveSheetView.SetValue(0,0,1);
}
<Serializable()>
Public Class myCheck
Inherits FarPoint.Web.Spread.CheckBoxCellType

Sub New(ByVal img1 As String,ByVal img2 As String)
MyBase.CheckedImageUrl=img1
MyBase.UncheckedImageUrl=img2
End Sub

Public Overrides Function Format(ByVal o As Object)As String
Return MyBase.Format(o)
End Function

Public Overrides Function GetEditorControl(ByVal id As String,ByVal tc As TableCell,ByVal style As FarPoint.Web.Spread.Appearance,ByVal margin As FarPoint.Web.Spread.Inset,ByVal v As Object,ByVal ul As Boolean)As System.Web.UI.Control
Return MyBase.GetEditorControl(id,tc,style,margin,v,ul)
End Function

Public Overrides Function GetEditorValue(ByVal owner As Control,ByVal id As String)As Object
Return MyBase.GetEditorValue(owner,id)
End Function

Public Overrides Function PaintCell(ByVal id As String,ByVal tc As TableCell,ByVal style As FarPoint.Web.Spread.Appearance,ByVal margin As FarPoint.Web.Spread.Inset,ByVal v As Object,ByVal ul As Boolean)As System.Web.UI.Control
Return MyBase.PaintCell(id,tc,style,margin,v,ul)
End Function

Public Overrides Function Parse(ByVal s As String)As Object
Return MyBase.Parse(s)
End Function

Public Overrides Function ValidateEditorValue(ByVal val As Object,ByRef reason As String)As Boolean
Return MyBase.ValidateEditorValue(val,reason)
End Function

Public ShadowsPropertyBooleanValue()As Boolean
Get
Return MyBase.BooleanValue
End Get
Set(ByVal ValueAsBoolean)
MyBase.BooleanValue=Value
End Set
End Property

Public ShadowsPropertyCheckedImageUrl()As String
Get
Return MyBase.CheckedImageUrl
End Get
Set(ByVal Value As String)
MyBase.CheckedImageUrl=Value
End Set
End Property

Public Overrides ReadOnly PropertyEditorClientScriptUrl()As String
Get
Return"checkboxeditor.htc"
End Get
End Property

Public Overrides ReadOnly PropertyRendererClientScriptUrl()As String
Get
Return"checkboxrender.htc"
End Get
End Property

Public ShadowsPropertyUncheckedImageUrl()As String
Get
Return MyBase.UncheckedImageUrl
End Get
Set(ByVal Value As String)
MyBase.UncheckedImageUrl=Value
End Set
End Property

End Class

Private SubPage_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load
Dim ckbox As New myCheck("img\checked.gif","img\unchecked.gif")
ckbox.BooleanValue=False
FpSpread1.ActiveSheetView.Cells(0,0).CellType=ckbox
FpSpread1.ActiveSheetView.SetValue(0,0,1)
EndSub
Requirements

Target Platforms: Windows 7, Windows 8, Windows Vista, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

Reference

CheckBoxCellType Class
CheckBoxCellType Members

 

 


Copyright © GrapeCity, inc. All rights reserved.