找回密码
 立即注册

QQ登录

只需一步,快速开始

sxjcjwl

银牌会员

9

主题

27

帖子

3249

积分

银牌会员

积分
3249

活字格认证

sxjcjwl
银牌会员   /  发表于:2011-12-13 08:58  /   查看:4924  /  回复:3
在spread for asp.net下,
    1.当选择组合框中的选项时,如何获取combobox的当前text与value;
      2.如果设置某一项为选择项。

3 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2011-12-13 09:58:00
沙发

回复 1# sxjcjwl 的帖子

sxjcjwl 你好,
1.通过 FpSpread1_ButtonCommand 事件,可以获取当前 combobox text 和 value 值。
2.在设置 comboboxcelltype 给单元格后,可以通过设置该单元格的 value 去设置初始选择项。
代码如下:

  1.         protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             FarPoint.Web.Spread.ComboBoxCellType combobox = new FarPoint.Web.Spread.ComboBoxCellType(new String[] { "One", "Two", "Three" });
  4.             combobox.Values = new string[3] { "1", "2", "3" };
  5.             combobox.AutoPostBack = true;
  6.             combobox.ShowButton = true;
  7.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = combobox;

  8.             //设置 2 为 起始项,对应 text 为 Tow
  9.             FpSpread1.ActiveSheetView.Cells[0, 0].Value = 2;
  10.         }

  11.         protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  12.         {
  13.            //获取当前单元格的行列索引
  14.             Point _test = (Point)e.CommandArgument;
  15.             int _row = _test.X;
  16.             int _col = _test.Y;
  17.             string _value = this.FpSpread1.ActiveSheetView.Cells[_row, _col].Value.ToString() ;
  18.             string _text = this.FpSpread1.ActiveSheetView.Cells[_row, _col].Text;
  19.         }
复制代码
回复 使用道具 举报
sxjcjwl
银牌会员   /  发表于:2011-12-13 11:57:00
板凳

回复 1# sxjcjwl 的帖子

ok!谢谢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2011-12-13 12:00:00
地板

回复 3# sxjcjwl 的帖子

不客气~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部