Marcel
Marcel

Reputation: 927

How to add a Row at Runtime to Devexpress Gridview

I'm using devexpress's gridview-control for showing information about files. You have to select a folder, and then the gridview is going to show the information, like this: name|date|size but I can't get it done to add a new row to the gridview. The name of it is gdFiles for example, but what would the command for adding a new line be? Something like gdFiles.insert(x,y,z)?

Upvotes: 0

Views: 10835

Answers (1)

DmitryG
DmitryG

Reputation: 17850

You can always use methods of your data source to add, delete and modify individual rows if the data source supports these methods:

BindingList<Person> personsList = new BindingList<Person>();
gridControl.DataSource = personsList;
//...
personsList.Add(new Person("John", "Smith")); // !!!

Or you can use the ColumnView.AddNewRow method to add a new row to a Grid View. For rows added using the ColumnView.AddNewRow method, you can write cell initialization code within a ColumnView.InitNewRow event handler.

Refer to the Adding and Deleting Records topic for more details on adding and deleting records via code.

Please also take a look at New Item Row Overview (this topic describes the new item row - a row that allows end-users to add new records.)

Upvotes: 1

Related Questions