简体   繁体   English

如何在运行时向Devexpress Gridview添加行

[英]How to add a Row at Runtime to Devexpress Gridview

I'm using devexpress's gridview-control for showing information about files. 我正在使用devexpress的gridview-control显示有关文件的信息。 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. 您必须选择一个文件夹,然后gridview将显示信息,如下所示:name | date | size,但是我无法完成将新行添加到gridview的过程。 The name of it is gdFiles for example, but what would the command for adding a new line be? 例如,它的名称是gdFiles,但是添加新行的命令是什么? Something like gdFiles.insert(x,y,z)? 像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. 或者,您可以使用ColumnView.AddNewRow方法向网格视图添加新行。 For rows added using the ColumnView.AddNewRow method, you can write cell initialization code within a ColumnView.InitNewRow event handler. 对于使用ColumnView.AddNewRow方法添加的行,可以在ColumnView.InitNewRow事件处理程序中编写单元格初始化代码。

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.) 还请查看“ 新项目行概述” (本主题描述了新项目行-允许最终用户添加新记录的行。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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