简体   繁体   English

c#datagridview删除最后一个条目行

[英]c# datagridview remove last entry row

I have problem with removing last row.我在删除最后一行时遇到问题。

Here is code这是代码

 private void ponistiPrethodni_Click(object sender, EventArgs e)
    {

        int lastEntry = glProstor.Rows.Count - 1;
        System.Diagnostics.Debug.WriteLine(lastEntry);
        glProstor.Rows.RemoveAt(lastEntry);

    }

I get exeption with我得到豁免

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll System.Windows.Forms.dll 中发生类型为“System.InvalidOperationException”的未处理异常

Additional information: Uncommitted new row cannot be deleted.附加信息:无法删除未提交的新行。

解决了,int lastEntry = glProstor.Rows.Count - 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM