简体   繁体   English

如何在我的自定义列中向Winforms DataGridView添加新行

[英]How to add a new row to Winforms DataGridView in my custom column

I have made a custom column for my DataGridView which is used in editable mode. 我为DataGridView制作了一个自定义列,该列用于可编辑模式。 While I am entering data in every column, the dataGrid automatically adds a new row as follows : 当我在每一列中输入数据时,dataGrid会自动添加新行,如下所示:

在此处输入图片说明

But in my custom column it does not happen. 但是在我的自定义列中却没有发生。

在此处输入图片说明

which part of the custom column is responsible for adding new rows and how should I do that. 自定义列的哪一部分负责添加新行,我该怎么做。

EDIT : I implemented three classes for my custom column : 编辑:我为自定义列实现了三个类:

public class DataGridViewLookupColumn : DataGridViewColumn {...}
public class DataGridViewLookupCell : DataGridViewTextBoxCell{...}
public class DataGridLookupControl : LookupControl, IDataGridViewEditingControl{...}

EDIT : I am filling my DatagridView using a binding source. 编辑:我正在使用绑定源填充我的DatagridView。

this.dataGrid.DataSource = BindingSource;
BindingSource.DataSource = model;
model=await this.EntityService.AdvancedSearchAsync(...);

above codes are gathered from three diffrent points in application to show structure of my data and application. 以上代码是从应用程序的三个不同点收集的,以显示我的数据和应用程序的结构。

Thanks in advance for your time and your consideration of course. 在此先感谢您的宝贵时间和对您的考虑。

I finally figured out how to solve it. 我终于想出了解决方法。 It's just 只是

DataGridView.NotifyCurrentCellDirty(true);

I added this code to my change event and my problem solved. 我将此代码添加到我的更改事件中,并解决了问题。

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

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