回复 3楼chcchb的帖子
请通过以下代码测试:
- public partial class WebForm1 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- InitSpread();
- }
- /// <summary>
- /// 初始化 Spread
- /// </summary>
- private void InitSpread()
- {
- //获取 ComboboxCellType 数据源
- DataSet ds = GetDataSet();
- //设置 ComboBoxCellType
- FarPoint.Web.Spread.ComboBoxCellType cb = new FarPoint.Web.Spread.ComboBoxCellType();
- cb.AllowWrap = true;
- cb.DataSource = ds;
- cb.ShowButton = true;
- cb.DataMember = "Heros";
- cb.DataTextField = "Name";
- cb.DataValueField = "ID";
- cb.UseValue = true;
- cb.AutoPostBack = true;
- cb.OnClientChanged = "alert('更改选项')";
- FpSpread1.ActiveSheetView.Cells[0, 0].CellType = cb;
- FpSpread1.ActiveSheetView.Cells[0, 0].Value = 1;
- }
- /// <summary>
- /// 设置数据源
- /// </summary>
- /// <returns>ComboBoxCellType 使用的数据源</returns>
- private DataSet GetDataSet()
- {
- DataSet ds = new System.Data.DataSet();
- DataTable name;
- name = ds.Tables.Add("Heros");
- name.Columns.AddRange(new DataColumn[] {new DataColumn("Name", typeof(string)), new DataColumn("ID", typeof
- (Int32))});
- name.Rows.Add(new object[] { "第一项", 0 });
- name.Rows.Add(new object[] { "更改值项", 1 });
- return ds;
- }
- }
复制代码 |