您好!
您可以运行以下代码实现您的需求:
ComboBoxCellType combo2 = new ComboBoxCellType();
public Form1()
{
InitializeComponent();
fpSpread1.EditModeOn += fpSpread1_EditModeOn;
ComboBoxCellType combo1 = new ComboBoxCellType();
combo1.Items = new string[] { "Item1", "Item2", "Item3", "Item4" };
combo1.EditorValue = EditorValue.Index;
fpSpread1.ActiveSheet.Cells[1, 1].CellType = combo1;
fpSpread1.ActiveSheet.Cells[2, 2].CellType = combo2;
}
void fpSpread1_EditModeOn(object sender, EventArgs e)
{
if (fpSpread1.ActiveSheet.ActiveCell.Row.Index == 1 && fpSpread1.ActiveSheet.ActiveCell.Column.Index == 1)
{
(fpSpread1.EditingControl as FpCombo).SelectedIndexChanged += Form1_SelectedIndexChanged;
}
}
void Form1_SelectedIndexChanged(object sender, EventArgs e)
{
if((sender as FpCombo).SelectedIndex == 0)
{
combo2.Items = new string[] { "Item1", "Item2", "Item3" };
}
if ((sender as FpCombo).SelectedIndex == 1)
{
combo2.Items = new string[] { "Item4", "Item5", "Item6" };
}
} |