简体   繁体   English

在最后一行输入数据 Datagridview c#

[英]Enter data in the last row Datagridview c#

I am working with DataGridView and I would like to know how I can maintain a permanent row to enter data in that DataGridView .我正在使用 DataGridView,我想知道如何维护一个永久行以在该 DataGridView 中输入数据 I ask this because I have a blank row at the beginning, but if I paste data, there is no row available to add more data.我问这个是因为我的开头有一个空白行,但是如果我粘贴数据,则没有可用于添加更多数据的行。 Then I have to add a blank one.然后我必须添加一个空白。

For example, this is my DataGridView:例如,这是我的 DataGridView:

在此处输入图像描述

And if I paste data into this data grid view, I have no more rows to add data:如果我将数据粘贴到这个数据网格视图中,我就没有更多的行来添加数据了:

在此处输入图像描述

So, is there any way to always keep a blank row?那么,有什么办法可以一直保留一个空行呢? Because in order not to have this problem, I am adding a new row whenever I paste data.因为为了不出现这个问题,我每次粘贴数据时都会添加一个新行。

( DataGridView.AllowUserToAddRows is enabled) (启用DataGridView.AllowUserToAddRows

And is there a way to paste data always in the last row?有没有办法总是在最后一行粘贴数据?

You can try by adding a row everytime you enter data with the event CellValueChanged, and use the code below您可以尝试在每次使用事件 CellValueChanged 输入数据时添加一行,并使用下面的代码

DataGridView.Rows.Add(row);

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

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