1. 程式人生 > >.Net 中使用Farpoint Web Spread 自定義CellType

.Net 中使用Farpoint Web Spread 自定義CellType

bsp inherits end app lean nbu appear rpo cti

網上關於Farpoint的文章不多,自己開發中有用到,寫來總結一下。

FarPoint.Web.Spread可以在單元格中控制自己需要的CellType。 但有時候我們所面對的需求五花八門,可能它自帶的CellType並不能滿足我們的需要,這時,我們就可以選擇自定義CellType。

一個自定義的HtmlInputButtonCellType的例子:

<Serializable()> Public Class PINButtonCellType
    Inherits FarPoint.Web.Spread.BaseCellType

    Public Value As String
    Public OnClick As String

    Public Overrides Function PaintCell(ByVal id As String, ByVal parent As TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal val As Object, ByVal ul As Boolean) As System.Web.UI.Control
        ‘Manual realize JS function on client FpCellType value + _getValue(rd) _setEditorValue(ed, val) _getEditorValue(ed) _setValue(rd,val)
parent.Attributes.Add("FpCellType", "PINButtonCellType") Dim lit As New System.Web.UI.HtmlControls.HtmlInputButton lit.Value = Value lit.Attributes.Add("onclick", String.Format(OnClick, val)) Return lit 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 Nothing 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 Format(ByVal o As Object) As String Format = MyBase.Format(o) End Function Public Overrides Function Parse(ByVal s As String) As Object Parse = MyBase.Parse(s) End Function Public Function GetValueFromText(ByVal s As String) As Object GetValueFromText = s End Function End Class

使用示例:

Dim btnCellType As New PINButtonCellType
btnCellType.Value = "Reset" ‘button name
btnCellType.OnClick = "ResetRadio(this)" ‘onclick function
fpsDemo.ActiveSheetView.Columns(0).CellType = btnCellType

.Net 中使用Farpoint Web Spread 自定義CellType