下拉列表加载数据(ComBobox)
列表追加
FarPoint.Win.Spread.CellType.ComboBoxCellType cb4 = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
cb4.ListWidth = 96;
cb4.Editable = true;
cb4.MaxDrop = 10;
cb4.MaxLength = 1;
string[] priceTagList = new string[]...{" 0 無し"," 1 有り"};
cb4.Items = priceTagList;
this.spdSetList.ActiveSheet.Columns[4].CellType = cb4;
数据库追加
FarPoint.Win.Spread.CellType.ComboBoxCellType cb12 = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
cb12.ListWidth = 150;
cb12.Editable = true;
cb12.MaxDrop = 10;
cb12.MaxLength = 8;
string[] employeeList = DataSetToArray(dsEmployee, 8);
cb12.Items = employeeList;
this.spdSetList.ActiveSheet.Columns[12].CellType = cb12;
private string[] DataSetToArray(DataSet ds, int BlankNum)
...{
int i = 0;
int NumLength = 0;
string[] returnArray = new string[ds.Tables[0].Rows.Count];
DataRow foundRows = ds.Tables[0].Rows[ds.Tables[0].Rows.Count -1];
NumLength = foundRows[0].ToString().Length;
foreach(DataRow dr in ds.Tables[0].Rows)
...{
returnArray[i] = dr[0].ToString().PadLeft(BlankNum, ' ') + " " + dr[1].ToString();
i++;
}
return returnArray;
}
本文介绍如何使用 FarPoint Spread 控件为 Excel 类似的工作表中的单元格设置下拉列表功能。具体包括从数组和数据库两种方式加载数据,并展示了如何配置 ComboBoxCellType 的属性。
985

被折叠的 条评论
为什么被折叠?



