//设置单元格为下拉框
FarPoint.Web.Spread.ComboBoxCellType combox = new FarPoint.Web.Spread.ComboBoxCellType();
//构建数据源
DataTable dtDropDownSouce = new DataTable();
dtDropDownSouce.Columns.AddRange(new DataColumn[] { new DataColumn("NAME", typeof(string)), new DataColumn("VALUES", typeof(string)) });
for (int i = 0; i < enumValues.Length; i++)
{
dtDropDownSouce.Rows.Add(new object[] { enumValues.GetValue(i), enumValues.GetValue(i) });
}
//绑定下拉框数据源
combox.AllowWrap = true;
combox.DataSource = dtDropDownSouce;
combox.ShowButton = true;
combox.DataTextField = "NAME";
combox.DataValueField = "VALUES";
combox.UseValue = true;
combox.AutoPostBack = true;
//设置单元格类型
FpSpread1.Sheets[spreadSheetIndex].Cells[spreadRowIndex, spreadColumnIndex].CellType = combox;
————————————————————————————————————————————————————————————————————
'设置单元格为下拉框
Dim combox As New FarPoint.Win.Spread.CellType.ComboBoxCellType()
'绑定下拉框数据源
Dim cbstr As String() = New String() {}
For i As Integer = 0 To enumValues.Length - 1
cbstr.SetValue(enumValues.GetValue(i), i)
Next
combox.Items = cbstr
'设置单元格类型
FpSpread1.Sheets(spreadSheetIndex).Cells(spreadRowIndex, spreadColumnIndex).CellType = combox
上下两块代码是表达的意思一样么? |