找回密码
 立即注册

QQ登录

只需一步,快速开始

tingche

银牌会员

17

主题

76

帖子

3877

积分

银牌会员

积分
3877

活字格认证

tingche
银牌会员   /  发表于:2013-4-23 16:23  /   查看:6168  /  回复:6
spread的cell里动态添加一个linkbutton如何实现???

6 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-4-23 17:44:00
沙发
回复 1楼tingche的帖子

tingche 你好,

Spread 提供 ButtonCellType 和 HyperLinkCellType,参考代码如下:

  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }

  7.             //按钮单元格类型
  8.             FarPoint.Web.Spread.ButtonCellType btn = new FarPoint.Web.Spread.ButtonCellType();

  9.             btn.ButtonType = FarPoint.Web.Spread.ButtonType.LinkButton;
  10.             btn.Text = "链接形式按钮";
  11.             this.FpSpread1.Sheets[0].Cells[0, 0].CellType = btn;

  12.             //超链接单元格类型
  13.             FarPoint.Web.Spread.HyperLinkCellType hlcell = new FarPoint.Web.Spread.HyperLinkCellType("str1");
  14.             hlcell.NavigateUrl = "http://www.gcpowertools.com.cn/";
  15.             hlcell.Target = "_self";
  16.             FpSpread1.ActiveSheetView.Cells[1, 0].CellType = hlcell;
  17.             FpSpread1.ActiveSheetView.Columns[0].Width = 150;
  18.         }
复制代码
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-4-24 09:17:00
板凳
感谢支持,想问一下,spread在对单元格设置value后,还能不能在单元格内添加一个linkbutton
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-4-24 13:24:00
地板
回复 2楼iceman的帖子

感谢支持,想问一下,spread在对单元格设置value后,还能不能在单元格内添加一个linkbutton
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-24 13:53:00
5#
回复 4楼tingche的帖子

请问进行这样的操作想实现的功能是?
可以通过以下代码测试:

  1.         protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }
  7.             this.FpSpread1.Sheets[0].Cells[0,0].Value=1;
  8.             FarPoint.Web.Spread.ButtonCellType btn = new FarPoint.Web.Spread.ButtonCellType();
  9.             btn.ButtonType = FarPoint.Web.Spread.ButtonType.LinkButton;
  10.             this.FpSpread1.Sheets[0].Cells[0, 0].CellType = btn;
  11.         }
复制代码


Debug 状态下,该单元格 Value 值仍然存在。
回复 使用道具 举报
tingche
银牌会员   /  发表于:2013-4-25 00:41:00
6#
回复 5楼iceman的帖子

意思就是,在一个cell里,我已经存在一个值,同时,在保持这个值的同时,在cell里再添加一个linkbutton控件,也就是在 cell里同时有值和button
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-4-25 09:28:00
7#
回复 6楼tingche的帖子

button 和 Value 可以同时存在。
可以通过 5# 中的代码测试。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部