让新行脏编程,并在DataGridView中后插入新行

编程入门 行业动态 更新时间:2024-10-10 23:19:05
本文介绍了让新行脏编程,并在DataGridView中后插入新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个可编辑的无限datagridview的。我编程方式更改新行的值。

I've an editable unbounded datagridview. I'm changing the value of new row programmatically.

通常,当在一新行的任何领域的用户类型,它变脏和另一个新的行被插入其下方。

Normally, when user types in any field of a new row, it becomes dirty and another new row is inserted below it.

但在我的情况下,当用户进来一个新行的任何领域,我捕捉功能键和编程方式更改单元格的值。

But in my case, when user comes in to any field of a new row, I'm trapping the function key and changing the cell value programmatically.

myGrid.CurrentCell.Value =XYZ;

myGrid.CurrentCell.Value = "xyz";

它不插入它下面的一个新行。

And it doesn't insert a new row below it.

现在作为一个工作,我身边试过这对CellValueChanged事件处理程序。

Now as a work around I tried this on CellValueChanged event handler.

if (myGrid.NewRowIndex == e.RowIndex) { myGrid.Rows.Insert(e.RowIndex + 1, 1); }

但它引发错误说没有行可以插入之后,未提交的新行。。

我怎么能告诉myGrid,我做了当前行(这是一个新行)和脏有需要的新行之后呢?

How could I tell myGrid that I've made current row (which is a new row) dirty and that there is need of a new row after it?

推荐答案

在这里,我得到了解决。

Here I got the solution

myGrid.NotifyCurrentCellDirty(true);

更多推荐

让新行脏编程,并在DataGridView中后插入新行

本文发布于:2023-10-26 18:11:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530943.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:并在   让新   DataGridView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!