簡體   English   中英

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

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

我為DataGridView制作了一個自定義列,該列用於可編輯模式。 當我在每一列中輸入數據時,dataGrid會自動添加新行,如下所示:

在此處輸入圖片說明

但是在我的自定義列中卻沒有發生。

在此處輸入圖片說明

自定義列的哪一部分負責添加新行,我該怎么做。

編輯:我為自定義列實現了三個類:

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

編輯:我正在使用綁定源填充我的DatagridView。

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

以上代碼是從應用程序的三個不同點收集的,以顯示我的數據和應用程序的結構。

在此先感謝您的寶貴時間和對您的考慮。

我終於想出了解決方法。 只是

DataGridView.NotifyCurrentCellDirty(true);

我將此代碼添加到我的更改事件中,並解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM