Spread ASP.NET 16
FarPoint.Web.Spread Assembly / FarPoint.Web.Spread Namespace / CheckBoxCellType Class / Format Method
Object in the data model from which to get formatting information
Example


In This Topic
    Format Method (CheckBoxCellType)
    In This Topic
    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.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using FarPoint.Web.Spread;
    using System.Drawing;
    using FarPoint.Web.Spread;
    
    public partial class Sample2 : System.Web.UI.Page
    {
        
      private void Page_Load(object sender,System.EventArgs e)
      {
        var bcTypecell = new myCheck("img\\checked.gif", "img\\unchecked.gif");
        FpSpread1.ActiveSheetView.Cells[0,0].CellType=bcTypecell;
        FpSpread1.ActiveSheetView.Columns[0].Width=130;
        FpSpread1.ActiveSheetView.Rows[0].Height=40;
      }
    }
    
    [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 string ValidateEditorValue(object val)
      {
        return base.ValidateEditorValue(val);
      }
    
      public override string EditorClientScriptUrl{get{return "checkboxeditor.htc";}}
    
      public override string RendererClientScriptUrl{get{return "checkboxrender.htc";}}
    }
    Imports FarPoint.Web.Spread
    Partial Class Sample2VB
      Inherits System.Web.UI.Page
    
      Private Sub Page_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")
        FpSpread1.ActiveSheetView.Cells(0, 0).CellType = ckbox
        FpSpread1.ActiveSheetView.SetValue(0, 0, 1)
      End Sub
    
    End Class
    
    <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) As String
        Return MyBase.ValidateEditorValue(val)
      End Function
      
    
      Public Shadows Property CheckedImageUrl() As String
        Get
          Return MyBase.CheckedImageUrl
        End Get
    
        Set(ByVal Value As String)
          MyBase.CheckedImageUrl = Value
        End Set
      End Property
    
      Public Overrides ReadOnly Property EditorClientScriptUrl() As String
        Get
          Return "checkboxeditor.htc"
        End Get
      End Property
    
      Public Overrides ReadOnly Property RendererClientScriptUrl() As String
        Get
          Return "checkboxrender.htc"
        End Get
      End Property
    
      Public Shadows Property UncheckedImageUrl() As String
        Get
          Return MyBase.UncheckedImageUrl
        End Get
        Set(ByVal Value As String)
          MyBase.UncheckedImageUrl = Value
        End Set
      End Property
    
    End Class
    See Also