将一个单元格的组合框添加到数据网格中 [英] adding combobox for one cell into the datagrid

查看:71
本文介绍了将一个单元格的组合框添加到数据网格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有数据网格形式,我想为一个特定的字段或单元创建组合框。我创建它吗?我使用下面的代码,但它显示整个列的组合框。我需要显示一个pariticular细胞的组合框。

任何人都可以提供解决方案。



Hi,
I have datagrid form and I want to create combobox for one particular field or cell.how do i create that?. i used below code but it shows combobox for whole column. and i need show combobox for one pariticular cell.
can anybody give solution.

private void Form4_Load(object sender, EventArgs e)
        {         
            ComboBox combobox1 = new ComboBox();
            combobox1.Hide();
            dataGridView1.Controls.Add(combobox1);
       }
  private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            ComboBox combobox1 = new ComboBox();
            combobox1.Location = dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Location;
            combobox1.SelectedValue = dataGridView1.CurrentCell.Value;
            combobox1.Show();
         }

推荐答案

而不是 ComboBox 单个 Cell ,为整列添加 ComboBox ComboBoxColumn [ ^ ]。它应该按预期工作。在页面底部,您将找到一个示例。
Instead ComboBox for single Cell, add ComboBox for entire column: ComboBoxColumn[^]. It should works as you expected. At the bottom of page you'll find an example.


这篇关于将一个单元格的组合框添加到数据网格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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