回复 3楼刘君的帖子
经调查,自定义单元格类型中的 Cell 没有设置 height 和 width 等样式,你可以尝试设置实现,以下是我的测试代码:
- 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;
- cell.Width = new Unit(96, UnitType.Percentage);
- cell.Height = new Unit(100, UnitType.Percentage);
- // 用户可以直接在 TextBox 中输入数据
- TextBox tb = new TextBox();
- tb.Width = new Unit(100, UnitType.Percentage);
- tb.ID = "PopupEditor" + _id;
- // 如果不希望用户直接输入数据,可以将TextBox设置为ReadOnly,这样就可以保证数据的有效性
- tb.ReadOnly = true;
- tb.BorderStyle = BorderStyle.None;
- if (!string.IsNullOrEmpty(_onEnterPopup))
- {
- tb.Attributes.Add("onkeydown", _onEnterPopup);
- }
- 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;
- cell.Width = new Unit(4, UnitType.Percentage);
- cell.Height= new Unit(100, UnitType.Percentage);
- // 如果用户不想通过输入的方式填写数据,可以点击[检索]按钮,在弹出的窗体中选择需要的数据
- ImageButton img = new ImageButton();
- img.ImageUrl = "~/img/(24,18).png";
- img.BorderStyle = BorderStyle.None;
- img.Width = new Unit(100, UnitType.Percentage);
- if (!string.IsNullOrEmpty(_onClickPopup))
- {
- img.Attributes.Add("onclick", _onClickPopup);
- }
- cell.Controls.Add(img);
- row.Cells.Add(cell);
- table.Rows.Add(row);
- //table.Style.Add("height", "100%");
- //table.Style.Add("width", "100%");
- return table;
- }
复制代码 |