Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As BaseCellType Dim o As Object Dim value As String value = instance.Format(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 sheetThis example subclasses the BaseCellType class and creates a custom cell type for the first cell in the spreadsheet. By double-clicking on the cell a new editor appears and the color of the cell can be changed by editing the RGB values in the editor.
C# | Copy Code |
---|---|
[Serializable()] classbcType:FarPoint.Web.Spread.BaseCellType { PublicoverridestringFormat(objecto) { ReturnBase.Format(o); } PublicoverrideControlGetEditorControl(stringid,TableCellparent,FarPoint.Web.Spread.Appearancestyle,FarPoint.Web.Spread.Insetmargin,objectv,boolul) { stringval=null,val1="",val2="",val3=""; If(v!=null) { val=v.ToString(); string[]colors=val.ToString().Split(Newchar[]{','}); If(colors.Length==3) { val1=colors[0].Trim(); val2=colors[1].Trim(); val3=colors[2].Trim(); } } Tabletable=NewTable(); table.CellPadding=0; table.CellSpacing=0; table.BorderWidth=0; TableRowrow=NewTableRow(); table.Rows.Add(row); TextBoxtb=NewTextBox(); tb.Text=val1; tb.Columns=3; If(ul) tb.Attributes.Add("MyEditorComp","Red"); If(id!=null) tb.ID=id+"c1"; TableCellcell=NewTableCell(); row.Cells.Add(cell); cell.Controls.Add(tb); tb=NewTextBox(); tb.Text=val2; tb.Columns=3; If(ul) tb.Attributes.Add("MyEditorComp","Green"); If(id!=null) tb.ID=id+"c2"; cell=NewTableCell(); row.Cells.Add(cell); cell.Controls.Add(tb); tb=NewTextBox(); tb.Text=val3; tb.Columns=3; If(ul) tb.Attributes.Add("MyEditorComp","Blue"); If(id!=null) tb.ID=id+"c3"; cell=NewTableCell(); row.Cells.Add(cell); cell.Controls.Add(tb); Returntable; } PublicoverrideobjectGetEditorValue(Controlowner,stringid) { ReturnBase.GetEditorValue(owner,id); } PublicoverrideBaseValidatorGetValidator() { ReturnBase.GetValidator(); } PublicoverrideControlPaintCell(stringid,TableCellparent,FarPoint.Web.Spread.Appearancestyle,FarPoint.Web.Spread.Insetmargin,objectval,boolul) { ApplyStyleTo(parent,style,margin,True); System.Web.UI.WebControls.Panelp=NewSystem.Web.UI.WebControls.Panel(); p.Controls.Add(NewLiteralControl("Double-Click")); p.BackColor=Color.Red; p.BorderStyle=BorderStyle.Solid; p.BorderColor=Color.Black; Returnp; } PublicoverrideobjectParse(strings) { ReturnBase.Parse(s); } NewPublicboolValidateEditorValue(objectval,outstringreason) { ReturnBase.ValidateEditorValue(val,outreason); } PublicoverridestringEditorClientScriptUrl{Get{Return"MyEditorScript.htc";}} PublicoverridestringRendererClientScriptUrl{Get{Return"MyRenderScript.htc";}} } PrivatevoidPage_Load(objectsender,System.EventArgse) { bcTypecell=NewbcType(); FpSpread1.ActiveSheetView.Cells[0,0].CellType=cell; FpSpread1.ActiveSheetView.Columns[0].Width=130; FpSpread1.ActiveSheetView.Rows[0].Height=40; |
Visual Basic | Copy Code |
---|---|
<Serializable()>PublicClassbcType InheritsFarPoint.Web.Spread.BaseCellType PublicOverridesFunctionFormat(ByValoAsObject)AsString ReturnMyBase.Format(o) EndFunction PublicOverridesFunctionGetEditorValue(ByValownerAsControl,ByValidAsString)AsObject ReturnMyBase.GetEditorValue(owner,id) EndFunction PublicOverridesFunctionGetValidator()AsBaseValidator ReturnMyBase.GetValidator EndFunction PublicOverridesFunctionPaintCell(ByValidAsString,ByValparentAsTableCell,ByValstyleAsFarPoint.Web.Spread.Appearance,ByValmarginAsFarPoint.Web.Spread.Inset,ByValvalAsObject,ByValulAsBoolean)AsSystem.Web.UI.Control ApplyStyleTo(parent,style,margin,True) DimpAsNewSystem.Web.UI.WebControls.Panel() p.Controls.Add(NewLiteralControl("Double-Click")) p.BackColor=Color.Red p.BorderStyle=BorderStyle.Solid p.BorderColor=Color.Black Returnp EndFunction PublicOverridesFunctionParse(ByValsAsString)AsObject ReturnMyBase.Parse(s) EndFunction PublicOverridesFunctionValidateEditorValue(ByValvalAsObject,ByRefreasonAsString)AsBoolean ReturnMyBase.ValidateEditorValue(val,reason) EndFunction PublicOverridesReadOnlyPropertyEditorClientScriptUrl()AsString Get Return"MyEditorScript.htc" EndGet EndProperty PublicOverridesReadOnlyPropertyRendererClientScriptUrl()AsString Get Return"MyRenderScript.htc" EndGet EndProperty PublicOverridesFunctionGetEditorControl(ByValidAsString,ByValtcAsTableCell,ByValstyleAsFarPoint.Web.Spread.Appearance,ByValmarginAsFarPoint.Web.Spread.Inset,ByValvAsObject,ByValulAsBoolean)AsSystem.Web.UI.Control DimvalAsString=Nothing Dimval1AsString="" Dimval2AsString="" Dimval3AsString="" DimuAsNewSystem.Web.UI.WebControls.Unit(0) WhileNotv=Nothing val=v.ToString() Dimcolors()AsString=val.ToString().Split(",",3) Ifcolors.Length=3Then val1=colors(0).Trim() val2=colors(1).Trim() val3=colors(2).Trim() EndIf EndWhile DimtableAsNewTable() table.CellPadding=0 table.CellSpacing=0 table.BorderWidth=u DimrowAsNewTableRow() table.Rows.Add(row) DimtbAsNewTextBox() tb.Text=val1 tb.Columns=3 IfulThen tb.Attributes.Add("MyEditorComp","Red") EndIf WhileNotid=Nothing tb.ID=id+"c1" EndWhile DimcellAsNewTableCell() row.Cells.Add(cell) cell.Controls.Add(tb) tb=NewTextBox() tb.Text=val2 tb.Columns=3 IfulThen tb.Attributes.Add("MyEditorComp","Green") EndIf WhileNotid=Nothing tb.ID=id+"c2" EndWhile cell=NewTableCell() row.Cells.Add(cell) cell.Controls.Add(tb) tb=NewTextBox() tb.Text=val3 tb.Columns=3 IfulThen tb.Attributes.Add("MyEditorComp","Blue") EndIf WhileNotid=Nothing tb.ID=id+"c3" EndWhile cell=NewTableCell() row.Cells.Add(cell) cell.Controls.Add(tb) Returntable EndFunction EndClass PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load DimcellAsNewbcType() FpSpread1.ActiveSheetView.Cells(0,0).CellType=cell FpSpread1.ActiveSheetView.Columns(0).Width=130 FpSpread1.ActiveSheetView.Rows(0).Height=40 EndSub |
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family