你可以同时设置 Items 和 ItemData ,并将ItemData作为ComboBox的值,然后取单元格的Value就可以得到ComboBox中选中项的Index
- private void Form1_Load(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.ComboBoxCellType combo = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
- string[] cbstr;
- cbstr = new String[] { "One", "Two", "Three" };
- string[] strval;
- strval = new String[] { "1", "2", "3" };
- combo.Items = cbstr;
- combo.ItemData = strval;
- combo.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData;
- fpSpread1.Sheets[0].Columns[0].CellType = combo;
- }
- private void 取值ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MessageBox.Show(fpSpread1.ActiveSheet.ActiveCell.Value.ToString());
- }
复制代码 |