简体   繁体   中英

convert custom collection to DataRow

I try to pass the value to DataRow type variable from custom collection like the codes bellow:

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

And the XPCollection is "a custom collection of objects".

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

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

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