下面就演示以下如何设置自定义的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