Spread for ASP.NET 7.0 Product Documentation
GetEditorControl Method
See Also  Example Support Options
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. HTC files are only supported with Microsoft Internet Explorer.
C#Copy Code
[Serializable()]
class bcType:FarPoint.Web.Spread.BaseCellType
{
public override string Format(object o)
{
return Base.Format(o);
}
public override Control GetEditorControl(string id,TableCell parent,FarPoint.Web.Spread.Appearance style,FarPoint.Web.Spread.Inset margin,object v,bool ul)
{
string val=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();
}
}

Table table=new Table();
table.CellPadding=0;
table.CellSpacing=0;
table.BorderWidth=0;

TableRow row=new TableRow();
table.Rows.Add(row);

TextBoxt b=new TextBox();
tb.Text=val1;
tb.Columns=3;
If(ul)
tb.Attributes.Add("MyEditorComp","Red");

If(id!=null)
tb.ID=id+"c1";

TableCell cell=new TableCell();
row.Cells.Add(cell);
cell.Controls.Add(tb);

tb=new TextBox();
tb.Text=val2;
tb.Columns=3;
If(ul)
tb.Attributes.Add("MyEditorComp","Green");

If(id!=null)
tb.ID=id+"c2";

cell=new TableCell();
row.Cells.Add(cell);
cell.Controls.Add(tb);

tb=new TextBox();
tb.Text=val3;
tb.Columns=3;

If(ul)
tb.Attributes.Add("MyEditorComp","Blue");

If(id!=null)
tb.ID=id+"c3";

cell=new TableCell();
row.Cells.Add(cell);
cell.Controls.Add(tb);

return table;
}
public override object GetEditorValue(Control owner,string id)
{
return Base.GetEditorValue(owner,id);
}

public override BaseValidatorGetValidator()
{
return Base.GetValidator();
}
public override ControlPaintCell(string id,TableCell parent,FarPoint.Web.Spread.Appearance style,FarPoint.Web.Spread.Inset margin,object val,bool ul)
{
ApplyStyleTo(parent,style,margin,True);
System.Web.UI.WebControls.Panel p=new System.Web.UI.WebControls.Panel();
p.Controls.Add(NewLiteralControl("Double-Click"));
p.BackColor=Color.Red;
p.BorderStyle=BorderStyle.Solid;
p.BorderColor=Color.Black;
return p;
}
public override objectParse(string s)
{
return Base.Parse(s);
}
new public bool ValidateEditorValue(object val,out string reason)
{
return Base.ValidateEditorValue(val,out reason);
}
public override stringEditorClientScriptUrl{Get{Return"MyEditorScript.htc";}}
public override stringRendererClientScriptUrl{Get{Return"MyRenderScript.htc";}}
}

private void Page_Load(objectsender,System.EventArgse)
{
bcTypecell=new bcType();
FpSpread1.ActiveSheetView.Cells[0,0].CellType=cell;
FpSpread1.ActiveSheetView.Columns[0].Width=130;
FpSpread1.ActiveSheetView.Rows[0].Height=40;
Visual BasicCopy Code
<Serializable()> Public Class bcType
    Inherits FarPoint.Web.Spread.BaseCellType

    Public Overrides Function Format(ByVal o As Object) As String
        Return MyBase.Format(o)
    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 GetValidator() As BaseValidator
        Return MyBase.GetValidator
    End Function

    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
        ApplyStyleTo(parent, style, margin, True)
        Dim p As New System.Web.UI.WebControls.Panel()
        p.Controls.Add(New LiteralControl("Double-Click"))
        p.BackColor = System.Drawing.Color.Red
        p.BorderStyle = BorderStyle.Solid
        p.BorderColor = System.Drawing.Color.Black
        Return p
    End Function

    Public Overrides Function Parse(ByVal s As String) As Object
        Return MyBase.Parse(s)
    End Function

    Public Overrides Function ValidateEditorValue(ByVal val As Object, ByRef reason As String) As Boolean
        Return MyBase.ValidateEditorValue(Val, reason)
    End Function

    Public Overrides ReadOnly Property EditorClientScriptUrl() As String
        Get
            Return "MyEditorScript.htc"
        End Get
    End Property

    Public Overrides ReadOnly Property RendererClientScriptUrl() As String
        Get
            Return "MyRenderScript.htc"
        End Get
    End Property

    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
        Dim val As String = Nothing
        Dim val1 As String = ""
        Dim val2 As String = ""
        Dim val3 As String = ""
        Dim u As New System.Web.UI.WebControls.Unit(0)

        While Not v = Nothing
            val = v.ToString()
            Dim colors() As String = val.ToString().Split(",", 3)
            If colors.Length = 3 Then
                val1 = colors(0).Trim()
                val2 = colors(1).Trim()
                val3 = colors(2).Trim()
            End If
        End While

        Dim table As New Table()
        table.CellPadding = 0
        table.CellSpacing = 0
        table.BorderWidth = u

        Dim row As New TableRow()
        table.Rows.Add(row)

        Dim tb As New TextBox()
        tb.Text = val1
        tb.Columns = 3

        If ul Then
            tb.Attributes.Add("MyEditorComp", "Red")
        End If
        While Not id = Nothing
            tb.ID = id + "c1"
        End While

        Dim cell As New TableCell()
        row.Cells.Add(cell)
        cell.Controls.Add(tb)

        tb = New TextBox()
        tb.Text = val2
        tb.Columns = 3
        If ul Then
            tb.Attributes.Add("MyEditorComp", "Green")
        End If

        While Not id = Nothing
            tb.ID = id + "c2"
        End While

        cell = New TableCell()
        row.Cells.Add(cell)
        cell.Controls.Add(tb)

        tb = New TextBox()
        tb.Text = val3
        tb.Columns = 3
        If ul Then
            tb.Attributes.Add("MyEditorComp", "Blue")
        End If

        While Not id = Nothing
            tb.ID = id + "c3"
        End While

        cell = New TableCell()
        row.Cells.Add(cell)
        cell.Controls.Add(tb)
        Return table
    End Function
End Class

Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load
Dim cell As New bcType()
FpSpread1.ActiveSheetView.Cells(0,0).CellType=cell
FpSpread1.ActiveSheetView.Columns(0).Width=130
FpSpread1.ActiveSheetView.Rows(0).Height=40
End Sub

Requirements

Target Platforms: Windows 7, Windows 8, Windows Vista, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.