嗨,Dof:
您好!
我将Spread控件的本身的Insert功能设置为False后是可以了.但是我还想在自定义单元格类型中增加一个属性,用于传值的。改如何增加一个单元格的类型?
在以下类中如何增加一个自定义的属性?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace PopupCellTypeDemo_Modal
{
[Serializable()]
public class PopupCellType : FarPoint.Web.Spread.GeneralCellType
{
public PopupCellType()
{
}
public string jsExecEvent
{
//??????????????????
}
public override System.Web.UI.Control GetEditorControl(string id, System.Web.UI.WebControls.TableCell parent, FarPoint.Web.Spread.Appearance style, FarPoint.Web.Spread.Inset margin, object value, bool upperLevel)
{
Table table = new Table();
table.CellPadding = 0;
table.CellSpacing = 0;
table.BorderStyle = BorderStyle.None;
table.BorderWidth = new Unit(0, UnitType.Pixel);
table.Width = new Unit(100, UnitType.Percentage);
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.VerticalAlign = VerticalAlign.Middle;
cell.HorizontalAlign = HorizontalAlign.Left;
// 用户可以直接在 TextBox 中输入数据
TextBox tb = new TextBox();
tb.Width = new Unit(99, UnitType.Percentage);
tb.ID = "opupEditor";
// 如果不希望用户直接输入数据,可以将TextBox设置为ReadOnly,这样就可以保证数据的有效性
// tb.ReadOnly = true;
tb.Attributes.Add("onkeydown", "return EnterPress(event);");
cell.Controls.Add(tb);
row.Cells.Add(cell);
cell = new TableCell();
cell.Width = new Unit(22, UnitType.Pixel);
cell.VerticalAlign = VerticalAlign.Middle;
cell.HorizontalAlign = HorizontalAlign.Right;
// 如果用户不想通过输入的方式填写数据,可以点击[检索]按钮,在弹出的窗体中选择需要的数据
ImageButton img = new ImageButton();
img.ImageUrl = @"Images/Search.jpg";
img.BorderColor = System.Drawing.Color.LightGray;
img.BorderStyle = BorderStyle.Solid;
img.BorderWidth = new Unit(1, UnitType.Pixel);
//img.Attributes.Add("onclick", "ShowPopup()");
img.Attributes.Add("onclick", jsExecEvent);
cell.Controls.Add(img);
row.Cells.Add(cell);
table.Rows.Add(row);
return table;
}
public override System.Web.UI.Control PaintCell(string id, System.Web.UI.WebControls.TableCell parent, FarPoint.Web.Spread.Appearance style, FarPoint.Web.Spread.Inset margin, object value, bool upperLevel)
{
System.Web.UI.WebControls.Panel p = new System.Web.UI.WebControls.Panel();
ApplyStyleTo(parent, style, margin, true);
if (value != null)
p.Controls.Add(new LiteralControl(value.ToString()));
else
p.Controls.Add(new LiteralControl());
return p;
}
public override string EditorClientScriptUrl
{
get
{
return "opupEditorScript.htc";
}
}
}
} |