为ComboBoxCellType指定自定义的ListControl

发布时间:2012/11/13 00:11 发布者:葡萄城产品团队

返回博客中心

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)

关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网