简体   繁体   English

将自定义集合转换为DataRow

[英]convert custom collection to DataRow

I try to pass the value to DataRow type variable from custom collection like the codes bellow: 我尝试将值传递给自定义集合中的DataRow类型变量,如下面的代码:

GridHitInfo downHitInfo = null;
DataRow row = gridView3.GetDataRow(downHitInfo.RowHandle);

But as I know that if the view's data source is a custom collection of objects, the GetDataRow method returns null (Nothing in Visual Basic). 但据我所知,如果视图的数据源是自定义对象集合,则GetDataRow方法返回null (在Visual Basic中为Nothing)。 If the view's data is supplied by the System.Data.DataTable or System.Data.DataView object , the System.Data.DataRow object representing a specific row is returned." 如果视图的数据由System.Data.DataTableSystem.Data.DataView object ,则返回表示特定行的System.Data.DataRow object 。“

And the XPCollection is "a custom collection of objects". XPCollection是“自定义对象集合”。

Is there any way that I could do to get the value from 我有什么方法可以从中获取价值

gridView3.GetDataRow(downHitInfo.RowHandle)?

Is there any converter or something needed? 有没有转换器或需要什么?

You can't get the DataRow object when the underlying Grid's data source not is DataTable or DataView. 当底层Grid的数据源不是DataTable或DataView时,您无法获取DataRow对象。 When the data source's type is XPCollection you should use the GetRow() method instead of the GetDataRow() method to get objects which correspond to grid rows: 当数据源的类型是XPCollection时,您应该使用GetRow()方法而不是GetDataRow()方法来获取与网格行对应的对象:

var xpCollection = new XPCollection<Person>();
gridControl1.DataSource = xpCollection;
//...
Person person = (Person)gridView1.GetRow(rowHandle);

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

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