Search code examples
c#winformsdatagridviewdesignerdatagridviewcolumn

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 :

enter image description here

But in my custom column it does not happen.

enter image description here

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.


Solution

  • 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.