PowerTools SPREAD for ASP.NET 8.0J
Parse メソッド (CheckBoxCellType)

解析対象の、シートのセルの文字列
この型に基づいてセル型を派生させるときに、このメソッドをオーバーライドすると、 シートのセルから解析され、データモデルに入力される内容が変化します。
構文
'Declaration
 
Public Overrides Function Parse( _
   ByVal s As String _
) As Object
public override object Parse( 
   string s
)

パラメータ

s
解析対象の、シートのセルの文字列

戻り値の型

データモデルにobjectとして設定する解析結果
以下の例では、CheckBoxCellTypeをサブクラス化し、スプレッドシートの先頭セル内にチェックボックス型セルを作成します。コンストラクタにON状態とOFF状態の画像を設定し、チェックボックスの状態に0または1の値を使用します。
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);
  }

}
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 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
参照

CheckBoxCellType クラス
CheckBoxCellType メンバ

 

 


© 2003-2015, GrapeCity inc. All rights reserved.