Spread ASP.NET 6.0 Product Documentation
GetEditorControl Method
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread Namespace > BaseCellType Class : GetEditorControl Method


id
Unique identifier of the control
parent
Parent cell (TableCell object) of the control
style
Style settings (Appearance object) for the control
margin
Margin settings (Inset object) for the control
value
Value (as object) to put in the control
upperLevel
Whether the control can render in an up-level browser

Glossary Item Box

Gets the control used to edit the cell.

Syntax

Visual Basic (Declaration) 
Public MustOverride Function GetEditorControl( _
   ByVal id As String, _
   ByVal parent As TableCell, _
   ByVal style As Appearance, _
   ByVal margin As Inset, _
   ByVal value As Object, _
   ByVal upperLevel As Boolean _
) As Control
Visual Basic (Usage)Copy Code
Dim instance As BaseCellType
Dim id As String
Dim parent As TableCell
Dim style As Appearance
Dim margin As Inset
Dim value As Object
Dim upperLevel As Boolean
Dim value As Control
 
value = instance.GetEditorControl(id, parent, style, margin, value, upperLevel)
C# 
public abstract Control GetEditorControl( 
   string id,
   TableCell parent,
   Appearance style,
   Inset margin,
   object value,
   bool upperLevel
)

Parameters

id
Unique identifier of the control
parent
Parent cell (TableCell object) of the control
style
Style settings (Appearance object) for the control
margin
Margin settings (Inset object) for the control
value
Value (as object) to put in the control
upperLevel
Whether the control can render in an up-level browser

Return Value

Control object containing the editor control to edit the cell

Remarks

The Spread component always positions the editor control returned by the GetEditorControl method so that the editor control covers the entire cell.

Example

This 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 BasicCopy 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

Requirements

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

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.