0
votes

I am using Devexpress gridcontrol. When I try to add new row or select row from the gridcontrol, it's not working.

gridControlMultiFilterValues.AddNewRow();

it throws error message like below

grid control does not contain a definition for AddNewRow and No extension method AddNewRow

Note : I tried SelectRow() method also. That is also not working

Update

FilterValues is my column name of GridControl. I have created this column by run designer.

(gridControlMultiFilterValues.MainView as DevExpress.XtraGrid.Views.Grid.GridView).AddNewRow();
int newRowHandle = (gridControlMultiFilterValues.MainView as DevExpress.XtraGrid.Views.Grid.GridView).FocusedRowHandle;

(gridControlMultiFilterValues.MainView as DevExpress.XtraGrid.Views.Grid.GridView).SetRowCellValue(newRowHandle, "FilterValues", "3rd Party %");

(gridControlMultiFilterValues.MainView as DevExpress.XtraGrid.Views.Grid.GridView).UpdateCurrentRow();
(gridControlMultiFilterValues.MainView as DevExpress.XtraGrid.Views.Grid.GridView).RefreshData();
1
I believe you should be using something like gridView1.AddNewRow() instead of GridView.AddNewRow(), or is GridView the actual variable name of the component? - Alisson
You need to create a reproducible example, currently, it's not clear what GridView is. - default locale
@Alisson my gridview component name is gridviewFields. I tried with gridviewFields.AddNewRow(). But it doesn't work - Liam neesan
@NiranjanKala can you help me? - Liam neesan

1 Answers

1
votes

Your error message indicates that you are trying to perform the AddNewRow and SelectRow methods on the GridControl, not the GridView.

When you drag the GridControl from the VS toolbox onto your form, a GridControl AND a GridView are created. The GridControl is the control which holds multiple GridView (see: View Technology).

This tells me that your GridControl is named gridviewFields. The GridView is a total separate class containing the methods you want to invoke. By default, it will be named gridView1 when a new GridControl is added to your form. You can also cast the GridControl's MainView property to an instance of a GridView at runtime:

(gridviewFields.MainView as DevExpress.XtraGrid.Views.Grid.GridView).AddNewRow();

Note that most of the properties and methods that you will use with regards to the DevExpress GridControl are actually members of the view, not the GridControl.