如何将datagridview文本框列更改为DataGridView ComboBox列... [英] how to change datagridview textbox column to DataGridView ComboBox column ...
本文介绍了如何将datagridview文本框列更改为DataGridView ComboBox列...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将DataGridView文本框列更改为C#中的DataGridView ComboBox列#
i试用以下代码但不工作
how to change DataGridView textbox column to DataGridView ComboBox column in c#
i tried following code but not working
private void dgv1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
e.Control.ContextMenu = new ContextMenu();
if ((dgv1.CurrentCell.ColumnIndex == 2))
{
DataGridViewComboBoxCell cc = new DataGridViewComboBoxCell();
cc.Items.AddRange(new string[] { "A/C Room", "Non A/C Room", "A/C Dormitory", "Non A/C Dormitory" });
}
}
但这不起作用,可以任何一个PLZ帮助我??
but this not working, Can any one plz help me??
推荐答案
这个链接可以帮到你
http://www.sommergyll.com/datagridview-usercontrols/datagridview-with-combobox.htm [ ^ ]
http://msdn.microsoft.com/en-us /library/system.windows.forms.datagridviewcomboboxcell.items.aspx [ ^ ]
-Ambi -
this link will help you
http://www.sommergyll.com/datagridview-usercontrols/datagridview-with-combobox.htm[^]
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcell.items.aspx[^]
-Ambi-
你好。我设法做了这样的事情。
首先我尝试使用CellBeginEdit和CellEndEdit,但没有出现ComboBox控件(只是它的可编辑框)。然后我使用了CellClick和CellValidating。它有效,但我必须解决可重入调用问题 - 最后我在网上找到解决方案。
我在这里解释:动态更改DataGridViewTextBoxCell到DataGridViewComboBoxCell
PS
如果您设法使用CellBeginEdit和CellEndEdit,请发布解决方案 - 我很好奇。
Hi. I managed to do something like this.
First I tried with CellBeginEdit and CellEndEdit but the ComboBox control didn't appear (just it's editable box). Then I used CellClick and CellValidating. It worked, but I had to solve the "reentrant call" problem - finally I find the solution on the net.
I explained it here: Dynamically change DataGridViewTextBoxCell to DataGridViewComboBoxCell
P.S.
If you manage to use CellBeginEdit and CellEndEdit, please post the solution here - I'm very curious about it.
这篇关于如何将datagridview文本框列更改为DataGridView ComboBox列...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文