将Combobox控件添加到datagrideview TextboxColumn单元格 [英] Adding Combobox control to datagrideview TextboxColumn cell
问题描述
您好,我在其中使用窗口应用程序和datagridview DGV填充到数据库表(Patient_name,Test_Name,Result,Reference_Ranges)中.我希望当Result列获得输入焦点时,出现一个组合框,用户从中选择值,但是想要组合框不用于结果列的所有单元格,因为在某些情况下,用户会从键盘输入值,因为组合框是只读的,并且该组合框的数据源已绑定到数据库,并为每个测试选择默认值; br/>
简而言之,我要这样
hi i am using window application and datagridview in it DGV is populated to a database table (patient_name,Test_Name,Result,Reference_Ranges).I want when the Result column receive input focus a combo box appear and user select value from it but want the combo box not for all cell of the result column because in some situation the user inter the value from keyboard because the combo box is read only and data source of that combo box is bond to database and select defrent value for each test ;
in short i want like this
DGV.rows[e.rowindex].cells["Result"].controls.add(cmb);
我已尽力并在网上搜寻,但失败了
我像这样添加cmb
i tried the best and search the net but fail
i add the cmb like this
DGV.controls.add(cmb);
但它出现在DGV的顶部,我希望它获得输入焦点的特定结果列单元格.
帮助我提供一些代码示例
感谢
but it appear at the top of DGV and i want it specific result column cell which receive input focus.
help me withe some sample of code
thanks
推荐答案
尝试一下
Try This
DataGridViewComboBoxColumn c = new DataGridViewComboBoxColumn();
dataGridView1.Columns.Add(c);
这篇关于将Combobox控件添加到datagrideview TextboxColumn单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!