DataGridview在文本框文本上生成另一行 [英] DataGridview Generating another row on textbox text enter
本文介绍了DataGridview在文本框文本上生成另一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview,里面有几个按钮和Combobox以及一个文本框。问题是当我开始输入文本框时,会出现一个新行。我不知道为什么?文本框文本后面没有代码。
i我觉得我需要问这样的问题
如何防止Datagridview不创建下一行。直到我点击特定按钮
I have a gridview which inside a couple of button and Combobox and a textbox. and the problem is as i start to type in textbox a new line do appear. I dont why? no code behind textboxes text.
i think i need to ask question like this
How to prevent Datagridview to not create next row. until i click on specific button
推荐答案
你需要将属性AllowUserToAddRows
设置为False(这可以在设计时或以编程方式完成,例如this.dataGridView1.AllowUserToAddRows = false;)。
添加下一行的按钮需要添加一行,然后将光标定位为用户输入,例如
You need to set the propertyAllowUserToAddRows
to False (this can be done at design time or programmatically e.g. this.dataGridView1.AllowUserToAddRows = false;).
Your button to add the next row will need to add a row, then position the cursor for user input e.g.
int i = this.dataGridView1.Rows.Add();
this.dataGridView1.CurrentCell = dataGridView1.Rows[i].Cells[0];
dataGridView1.BeginEdit(true);
这篇关于DataGridview在文本框文本上生成另一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文