sxjcjwl 你好,
1.通过 FpSpread1_ButtonCommand 事件,可以获取当前 combobox text 和 value 值。
2.在设置 comboboxcelltype 给单元格后,可以通过设置该单元格的 value 去设置初始选择项。
代码如下:
- protected void Page_Load(object sender, EventArgs e)
- {
- FarPoint.Web.Spread.ComboBoxCellType combobox = new FarPoint.Web.Spread.ComboBoxCellType(new String[] { "One", "Two", "Three" });
- combobox.Values = new string[3] { "1", "2", "3" };
- combobox.AutoPostBack = true;
- combobox.ShowButton = true;
- FpSpread1.ActiveSheetView.Cells[0, 0].CellType = combobox;
- //设置 2 为 起始项,对应 text 为 Tow
- FpSpread1.ActiveSheetView.Cells[0, 0].Value = 2;
- }
- protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
- {
- //获取当前单元格的行列索引
- Point _test = (Point)e.CommandArgument;
- int _row = _test.X;
- int _col = _test.Y;
- string _value = this.FpSpread1.ActiveSheetView.Cells[_row, _col].Value.ToString() ;
- string _text = this.FpSpread1.ActiveSheetView.Cells[_row, _col].Text;
- }
复制代码 |