FarPoint.Web.Spread Assembly / FarPoint.Web.Spread Namespace / BaseCellType Class / GetEditorValue Method
FpSpread component that owns this editor control
Unique identifier used by the FpSpread component to identify this editor control
Example


In This Topic
GetEditorValue Method (BaseCellType)
In This Topic
Gets the value from the editing control used for the cell.
Syntax
'Declaration
 
Public Overridable Function GetEditorValue( _
   ByVal owner As Control, _
   ByVal id As String _
) As Object
 
'Usage
 
Dim instance As BaseCellType
Dim owner As Control
Dim id As String
Dim value As Object
 
value = instance.GetEditorValue(owner, id)

Parameters

owner
FpSpread component that owns this editor control
id
Unique identifier used by the FpSpread component to identify this editor control

Return Value

Object containing the value from the editor control
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 by Microsoft Internet Explorer.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FarPoint.Web.Spread;
using System.Drawing;

public partial class SampleCode_Sample1 : System.Web.UI.Page
{
    
  private void Page_Load(object sender,System.EventArgs e)
  {
    var bcTypecell=new bcType();
    FpSpread1.ActiveSheetView.Cells[0,0].CellType=bcTypecell;
    FpSpread1.ActiveSheetView.Columns[0].Width=130;
    FpSpread1.ActiveSheetView.Rows[0].Height=40;
  }
}

[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(new char[]{','});
      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);

    TextBox tb=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 BaseValidator GetValidator()
  {
    return base.GetValidator();
  }

  public override Control PaintCell(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(new LiteralControl("Double-Click"));
    p.BackColor=Color.Red;
    p.BorderStyle=BorderStyle.Solid;
    p.BorderColor=Color.Black;
    return p;
  }

  public override object Parse(string s)
  {
  return base.Parse(s);
  }

  public override string ValidateEditorValue(object val)
  {
    return base.ValidateEditorValue(val);
  }

  public override string EditorClientScriptUrl{get{return "MyEditorScript.htc";}}
  public override string RendererClientScriptUrl{get{return "MyRenderScript.htc";}}
}
See Also