Spread for WinForms 提供的ComboBoxCellType单元格类型,为我们暴露了 ListControl 属性,通过该属性我们可以为 ComboBoxCellType 指定自定义的 ListBox 控件。

下面就演示以下如何设置自定义的ListBox控件,并为ListBox添加键盘事件,在窗体的Load事件中添加以下代码:
 
private void Form1_Load(object sender, EventArgs e)

    {

        FarPoint.Win.Spread.CellType.ComboBoxCellType cmbocell = new FarPoint.Win.Spread.CellType.ComboBoxCellType();

        ListBox list = new ListBox();

        list.Items.AddRange(new Object[] { "One", "Two", "Three" });

        list.KeyDown += new KeyEventHandler(list_KeyDown);

        cmbocell.ListControl = list;

        cmbocell.Items = (new String[] { "One", "Two", "Three" });

        fpSpread1.ActiveSheet.Columns[0].CellType = cmbocell;

    }

复制代码
指定ListBox的KeyDown事件:
 
void list_KeyDown(object sender, KeyEventArgs e)

    {

        System.Diagnostics.Debug.WriteLine(e.KeyValue);

    }

复制代码
源码下载:Vs2010 + Spread .NET 6
6698_KeyDown.zip (10.19 K, 下载次数:3)