我想在按下按鈕時添加一行新行。在datagridview中它會是: datagridview1.Rows.Add()如何在devexpress gridcontrol中添加新行(WinForms C#)
什麼是在gridcontrol中的等效代碼?請幫幫我。
我想在按下按鈕時添加一行新行。在datagridview中它會是: datagridview1.Rows.Add()如何在devexpress gridcontrol中添加新行(WinForms C#)
什麼是在gridcontrol中的等效代碼?請幫幫我。
DevExpress GridControl
必須始終綁定到數據源:您不能直接將行添加到GridControl
對象或其子GridViews
。
相反,您必須將您的GridControl
綁定到數據源(通過GridControl.DataSource
屬性),並通過此數據源添加/刪除行。
請參閱DevExpress站點的'Binding To Data'文檔,以獲取有關GridControl
可使用的數據源類型的更多信息。
您不能直接向您的GridControl
添加新行,因爲這只是視圖的容器。但是,如果您在GridControl
(或ColumnView的任何其他後代)中使用GridView
,則可以使用AddNewRow()
方法添加新行。
(myGridcontrol.MainView as DevExpress.XtraGrid.Views.Grid.GridView).AddNewRow();
編輯:您可以訪問以不同的方式您的看法,當然。
您可以使用AddNewRow添加新行並將SetRowCellValue插入到該行中。
yourgridViewName.AddNewRow();
yourgridViewName.SetRowCellValue(rowhandle,columnName,value);
gridViewMappedFileds.UpdateCurrentRow();
將yourgridName.RowCount-1 rowhandle在last.Put gridViewMappedFileds.Columns [ 「的ColumnName」]插入行給你列名。
儘管我的評論如下,這確實是正確的答案。 – pixelbadger