让新行脏编程,并在DataGridView中后插入新行 [英] Make new row dirty programmatically and insert a new row after it in DataGridView

查看:197
本文介绍了让新行脏编程,并在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中后插入新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆