【セル型】 設定されているセル型のプロパティ値を取得、変更する方法
対象製品
SPREAD for ASP.NET 8.0J
詳細
以下のサンプルコードのように、セル型のインスタンスを生成することで、各クラスメンバのプロパティ値を取得、変更することができます。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Return
End If
' テキスト型セルを定義し、最大入力可能文字数を5にします
Dim tc As New FarPoint.Web.Spread.TextCellType
tc.MaxLength = 5
FpSpread1.ActiveSheetView.Cells(1, 0).CellType = tc
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
' クライアントの変更を確定します
FpSpread1.SaveChanges()
' 対象となるセルのインスタンスを生成し、MaxLengthプロパティの値を参照します
Dim t As FarPoint.Web.Spread.TextCellType
t = CType(FpSpread1.ActiveSheetView.GetCellType(1, 0), FarPoint.Web.Spread.TextCellType)
FpSpread1.ActiveSheetView.Cells(1, 1).Value = t.MaxLength.ToString()
' MaxLengthプロパティの値を変更します
t.MaxLength = 10
End Sub
If IsPostBack Then
Return
End If
' テキスト型セルを定義し、最大入力可能文字数を5にします
Dim tc As New FarPoint.Web.Spread.TextCellType
tc.MaxLength = 5
FpSpread1.ActiveSheetView.Cells(1, 0).CellType = tc
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
' クライアントの変更を確定します
FpSpread1.SaveChanges()
' 対象となるセルのインスタンスを生成し、MaxLengthプロパティの値を参照します
Dim t As FarPoint.Web.Spread.TextCellType
t = CType(FpSpread1.ActiveSheetView.GetCellType(1, 0), FarPoint.Web.Spread.TextCellType)
FpSpread1.ActiveSheetView.Cells(1, 1).Value = t.MaxLength.ToString()
' MaxLengthプロパティの値を変更します
t.MaxLength = 10
End Sub
◎サンプルコード(C#)
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
return;
}
// テキスト型セルを定義し、最大入力可能文字数を5にします
FarPoint.Web.Spread.TextCellType tc = new FarPoint.Web.Spread.TextCellType();
tc.MaxLength = 5;
FpSpread1.ActiveSheetView.Cells[1, 0].CellType = tc;
}
protected void Button1_Click(object sender, EventArgs e)
{
// クライアントの変更を確定します
FpSpread1.SaveChanges();
// 対象となるセルのインスタンスを生成し、MaxLengthプロパティの値を参照します
FarPoint.Web.Spread.TextCellType t;
t = (FarPoint.Web.Spread.TextCellType)FpSpread1.ActiveSheetView.GetCellType(1, 0);
FpSpread1.ActiveSheetView.Cells[1, 1].Value = t.MaxLength.ToString();
// MaxLengthプロパティの値を変更します
t.MaxLength = 10;
}
{
if (IsPostBack)
{
return;
}
// テキスト型セルを定義し、最大入力可能文字数を5にします
FarPoint.Web.Spread.TextCellType tc = new FarPoint.Web.Spread.TextCellType();
tc.MaxLength = 5;
FpSpread1.ActiveSheetView.Cells[1, 0].CellType = tc;
}
protected void Button1_Click(object sender, EventArgs e)
{
// クライアントの変更を確定します
FpSpread1.SaveChanges();
// 対象となるセルのインスタンスを生成し、MaxLengthプロパティの値を参照します
FarPoint.Web.Spread.TextCellType t;
t = (FarPoint.Web.Spread.TextCellType)FpSpread1.ActiveSheetView.GetCellType(1, 0);
FpSpread1.ActiveSheetView.Cells[1, 1].Value = t.MaxLength.ToString();
// MaxLengthプロパティの値を変更します
t.MaxLength = 10;
}
キーワード
セル型