作成日: 2019/04/17 最終更新日: 2019/04/17
文書種別
使用方法
詳細
LockedプロパティをTrueにして編集を禁止した場合、セル内の文字列の一部を選択してコピーすることはできません。
代替法としては、readonly属性を設定した独自のセル型を使用する方法が考えられます。
◎サンプルコード(VB)
◎サンプルコード(C#)
代替法としては、readonly属性を設定した独自のセル型を使用する方法が考えられます。
◎サンプルコード(VB)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Return
End If
FpSpread1.ActiveSheetView.Cells(0, 0).CellType = New CustomCell()
End Sub
<Serializable()>
Public Class CustomCell
Inherits FarPoint.Web.Spread.TextCellType
Public Overrides Function GetEditorControl(ByVal id As String, ByVal parent As System.Web.UI.WebControls.TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal value As Object, ByVal upperLevel As Boolean) As System.Web.UI.Control
' 既定の処理をコメントアウト
'Return MyBase.GetEditorControl(id, parent, style, margin, value, upperLevel)
' ReadOnlyに設定したTextBoxを編集時に使用
Dim tb As TextBox = CType(MyBase.GetEditorControl(id, parent, style, margin, value, upperLevel), TextBox)
tb.Attributes("readonly") = "readonly"
Return tb
End Function
End Class
If IsPostBack Then
Return
End If
FpSpread1.ActiveSheetView.Cells(0, 0).CellType = New CustomCell()
End Sub
<Serializable()>
Public Class CustomCell
Inherits FarPoint.Web.Spread.TextCellType
Public Overrides Function GetEditorControl(ByVal id As String, ByVal parent As System.Web.UI.WebControls.TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal value As Object, ByVal upperLevel As Boolean) As System.Web.UI.Control
' 既定の処理をコメントアウト
'Return MyBase.GetEditorControl(id, parent, style, margin, value, upperLevel)
' ReadOnlyに設定したTextBoxを編集時に使用
Dim tb As TextBox = CType(MyBase.GetEditorControl(id, parent, style, margin, value, upperLevel), TextBox)
tb.Attributes("readonly") = "readonly"
Return tb
End Function
End Class
◎サンプルコード(C#)
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) return;
FpSpread1.ActiveSheetView.Cells[0, 0].CellType = new CustomCell();
}
[Serializable]
public class CustomCell : FarPoint.Web.Spread.TextCellType
{
public override Control GetEditorControl(string id, System.Web.UI.WebControls.TableCell parent, FarPoint.Web.Spread.Appearance style, FarPoint.Web.Spread.Inset margin, object value, bool upperLevel)
{
// 既定の処理をコメントアウト
//return base.GetEditorControl(id, parent, style, margin, value, upperLevel);
// ReadOnlyに設定したTextBoxを編集時に使用
TextBox tb = base.GetEditorControl(id, parent, style, margin, value, upperLevel) as TextBox;
tb.Attributes["readonly"] = "readonly";
return tb;
}
}
{
if (Page.IsPostBack) return;
FpSpread1.ActiveSheetView.Cells[0, 0].CellType = new CustomCell();
}
[Serializable]
public class CustomCell : FarPoint.Web.Spread.TextCellType
{
public override Control GetEditorControl(string id, System.Web.UI.WebControls.TableCell parent, FarPoint.Web.Spread.Appearance style, FarPoint.Web.Spread.Inset margin, object value, bool upperLevel)
{
// 既定の処理をコメントアウト
//return base.GetEditorControl(id, parent, style, margin, value, upperLevel);
// ReadOnlyに設定したTextBoxを編集時に使用
TextBox tb = base.GetEditorControl(id, parent, style, margin, value, upperLevel) as TextBox;
tb.Attributes["readonly"] = "readonly";
return tb;
}
}
旧文書番号
83897