2012-10-06 30 views
3

我嘗試從自定義集合傳遞價值的DataRow類型變量像波紋管代碼:轉換定製收集到的DataRow

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

但我知道,如果視圖的數據源對象的自定義集合, GetDataRow方法返回null(在Visual Basic中爲Nothing)。返回如果視圖的數據由System.Data.DataTableSystem.Data.DataView object,該System.Data.DataRow object代表一個特定的行提供。」

而且XPCollection是‘對象的定製集合’。

有什麼辦法,我可以做從

gridView3.GetDataRow(downHitInfo.RowHandle)? 

獲得的價值是否有任何需要轉換的東西?

+0

見我回答這個職位http://stackoverflow.com/questions/12762617/how-to-get-selected-row-values-of-devexpress-xtragrid –

回答

1

你不能得到DataRow對象當底層網格的數據源不爲DataTa ble或DataView。當數據源的類型是XPCollection你應該使用GetRow()方法,而不是GetDataRow()方法來獲得對應於網格行對象:

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

「當底層網格的數據源不是DataTable或DataView時,您無法獲得DataRow對象。」...我沒有相信這是正確的。 –