如何在运行时向Devexpress Gridview添加行 [英] How to add a Row at Runtime to Devexpress Gridview

查看:740
本文介绍了如何在运行时向Devexpress Gridview添加行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用devexpress的gridview-control来显示有关文件的信息。
您必须选择一个文件夹,然后gridview将显示信息,如下所示:name | date | size
,但是我无法完成将新行添加到gridview的操作。
例如,它的名称是gdFiles,但是添加新行的命令是什么?像gdFiles.insert(x,y,z)之类的东西?

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")); // !!!

或者您可以使用 ColumnView.AddNewRow 方法可向网格视图添加新行。对于使用 ColumnView.AddNewRow 方法添加的行,可以在 ColumnView.InitNewRow 事件处理程序。

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

这篇关于如何在运行时向Devexpress Gridview添加行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆