如何在DataGridViewComboBoxColumn中更改单元格的ComboBox样式 [英] How to change cell's ComboBox style in DataGridViewComboBoxColumn

查看:75
本文介绍了如何在DataGridViewComboBoxColumn中更改单元格的ComboBox样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DataGridViewComboBoxColumn中的单元格具有ComboBoxStyle DropDownList。这意味着用户只能从下拉列表中选择值。底层控件是ComboBox,所以它可以有样式DropDown。如何更改DataGridViewComboBoxColumn中底层组合框的样式。或者,更一般的是,我可以在DataGridView中列出一个用户可以输入的下拉列吗?

Cells in DataGridViewComboBoxColumn have ComboBoxStyle DropDownList. It means the user can only select values from the dropdown. The underlying control is ComboBox, so it can have style DropDown. How do I change the style of the underlying combo box in DataGridViewComboBoxColumn. Or, more general, can I have a column in DataGridView with dropdown where user can type?

推荐答案

void dataGridView1_EditingControlShowing(object sender, 
    DataGridViewEditingControlShowingEventArgs e)
{
    if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl))
    {
        DataGridViewComboBoxEditingControl cbo = 
            e.Control as DataGridViewComboBoxEditingControl;
        cbo.DropDownStyle = ComboBoxStyle.DropDown;
    }
}

组合框和数据绑定datagridview的问题

这篇关于如何在DataGridViewComboBoxColumn中更改单元格的ComboBox样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆