回复 1楼暗影忍者的帖子
请参考以下代码设置 Combo 和 CheckBox 单元格类型:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- GetSelect();
- }
- }
- //查询数据
- public void GetSelect()
- {
- FpSpread1.Height = 330;
- FpSpread1.Width = 1024;
- FpSpread1.Sheets[0].ColumnCount = 5;
- FpSpread1.Sheets[0].RowCount = 100;
- //DataSet ds = testServer.CrystalServer();
- DataSet ds = GetSpreadDateSource();
- FpSpread1.DataSource = ds;
- FpSpread1.DataBind();
- FpSpread1.Sheets[0].Columns[0].DataField = "aid";
- FpSpread1.Sheets[0].Columns[1].DataField = "username";
- FpSpread1.Sheets[0].Columns[2].DataField = "password";
- FpSpread1.Sheets[0].Columns[3].DataField = "sex";
- FpSpread1.Sheets[0].Columns[4].DataField = "phone";
- FpSpread1.Sheets[0].Columns[5].DataField = "state";
- //FpSpread1.Sheets[0].Cells[1, 1].Text = "80726116";
- //type 设置下拉框
- //DataSet dsType = testServer.SelUserType();
- FarPoint.Web.Spread.ComboBoxCellType cb = new FarPoint.Web.Spread.ComboBoxCellType();
- cb.AllowWrap = true;
- cb.DataSource = ds;
- cb.ShowButton = true;
- cb.DataTextField = "sex";
- cb.DataValueField = "sex";
- cb.UseValue = true;
- cb.AutoPostBack = true;
- FpSpread1.ActiveSheetView.Columns[3].CellType = cb;
- //Tax and Cleared 设置单选框
- FarPoint.Web.Spread.CheckBoxCellType ck = new FarPoint.Web.Spread.CheckBoxCellType();
- ck.AutoPostBack = true;
- }
- private DataSet GetSpreadDateSource()
- {
- DataSet ds = new DataSet();
- DataTable dt = new DataTable();
- dt.Columns.Add("aid");
- dt.Columns.Add("username");
- dt.Columns.Add("password");
- dt.Columns.Add("sex");
- dt.Columns.Add("phone");
- dt.Columns.Add("state",typeof(System.Boolean));
- dt.Rows.Add("11", "simith", "******", "男", "14784585954", true);
- dt.Rows.Add("11", "simith", "******", "男", "14784585954", true);
- dt.Rows.Add("11", "simith", "******", "女", "14784585954", false);
- dt.Rows.Add("11", "simith", "******", "男", "14784585954", true);
- dt.Rows.Add("11", "simith", "******", "女", "14784585954", false);
- ds.Tables.Add(dt);
- return ds;
- }
复制代码
CheckBox --> 对应为 Bool
ComboBox -->无,需要自己组织数据源设置
Button -->无,需要绑定后,手动设置 |