如何与QUOT;完成"一个新的行 [英] How to "finalize" a new row
问题描述
所以,我一直在运行了一些麻烦与我的C#Windows今晚窗体应用程序。是否可以插入新行以一个DataGridView时,当前选择的新行仍是其默认值吗?或者,如果我想以编程方式更改的值,我怎么能效仿编辑文本框,以便最终确定该行的用户?
So I've been running into some trouble tonight with my c# windows forms application. Is it possible to insert a new row to a datagridview when the currently selected new row is still on its default values? Or, if I want to change the values programmatically, how can I emulate the user editing the textbox in order to finalize the row?
要澄清一下,当行是一个新行(并显示了与 isNewRow
属性为真),我想不出如何改变了<$的C $ C> isNewRow = TRUE 状态,产生以下新的空行。
To clarify, when a row is a new row (and shows up as true with the isNewRow
property), I cannot figure out how to change out of the isNewRow = true
state to generate a new empty row below.
我已经试过 dataGridView.EndEdit()
, dataGridView.CurrentRow.DataGridView.EndEdit()
, bindingSource.EndEdit()
,而这些都没有真正做的伎俩。 (此外,使用 dataGridView.BeginEdit()
把文本框为编辑模式
,这是不是很方便,因为我似乎无法编程后修改单元格)
I've tried dataGridView.EndEdit()
, dataGridView.CurrentRow.DataGridView.EndEdit()
, bindingSource.EndEdit()
, and none of these have really done the trick. (also, using dataGridView.BeginEdit()
puts the text box into editmode
, which isn't handy, because I can't seem to edit the cell programmatically after that)
在理想情况下,我希望能够继续创出进入新行,同时改变他们的价值观与自定义的控制,或没有,有一个新行出现下方。
Ideally, I would like to be able to continue to hit enter on new rows, while changing their values with a custom control, or not, and have a new row appear underneath.
有没有人有任何解决这个?
Does anyone have any solutions to this?
推荐答案
好了,所以我想通了如何使这项工作。 当修改使用我的自定义控件的价值观,我不得不使用
Okay so I figured how to make this work. When modifying the values using my custom control, I had to use
bindingSource.EndEdit();
dataGridView.NotifyCurrentCellDirty(true);
dataGridView.EndEdit();
dataGridView.NotifyCurrentCellDirty(false);
因此,只要更改了新行,它会强制犯行,并增加了一个新的空行空间到DataGridView的结束。
So whenever changes are made to the new row, it forces the row to be committed and adds a new blank row space to the end of the datagridview.
我没有然而,使用验证()。
I did not have to use Validate(), however.
这篇关于如何与QUOT;完成&QUOT;一个新的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!