How to add a Row at Runtime to Devexpress Gridview

梦想的初衷 提交于 2019-12-11 20:15:05

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/28297734/how-to-add-a-row-at-runtime-to-devexpress-gridview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!