简体   繁体   中英

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. While I am entering data in every column, the dataGrid automatically adds a new row as follows :

在此处输入图片说明

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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