Datagridview禁用组合框上的新行添加选项所选索引已更改 [英] Datagridview disable the new row adding option on combobox selected index changed
本文介绍了Datagridview禁用组合框上的新行添加选项所选索引已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个datagridview组合框列,当我从combox中选择一个项目时,会添加新行.
如何禁用此功能?我已经使用了以下代码,但仍无法正常工作.
Hi All,
I have a datagridview combobox column and when I select an item from the combox a new row gets added.
How can I disable this? I have used the below code but it is still not working.
void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control is ComboBox)
{
combo = (ComboBox)e.Control;
if (combo != null)
{
combo.SelectedIndexChanged += new EventHandler(combo_SelectedIndexChanged);
}
currentCell = this.dataGridView1.CurrentCell;
combo.TextChanged += new EventHandler(combo_TextChanged);
}
void combo_TextChanged(object sender, EventArgs e)
{
this.dataGridView1.NotifyCurrentCellDirty(true);
}
请帮忙!!!!
Please help!!!!
推荐答案
您是要避免在datagridview中出现新行吗?
然后在formload事件中尝试此操作
do you mean you want to avoid that new line occurring in datagridview??
then try this in formload event
dataGridView1.AllowUserToAddRows = false;
希望对您有帮助!
hope it helps!!
这篇关于Datagridview禁用组合框上的新行添加选项所选索引已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文