简体   繁体   中英

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)?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM