2017-09-14 64 views
0

我有一個xtragrid,我填充並有2個未綁定的列。一切工作正常,除非我去過濾列,正確的過濾器彈出顯示,但當我雙擊一個值我得到一個nullreference異常。我設法找到異常的位置,它在我的方法CustomColumnUnboundData中,我嘗試從當前行獲取當前對象,並且該對象爲null。你可以幫我嗎?我究竟做錯了什麼 ? e.ListSourceRowIndex或GetRow()似乎不適用於過濾...devexpress - winforms中 - xtragrid - 過濾未綁定的列數據拋出NullReference異常

 private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) 
    { 
     GridView gridView = (GridView)sender; 

     int dataSourceIndex = e.ListSourceRowIndex; 

     Person person = (Person)gridView.GetRow(dataSourceIndex); 

     if (e.Column.FieldName == "name" && e.IsGetData) 
     { 
      e.Value = person.PersonKey.Name; 
     } 

     if (e.Column.FieldName == "surname" && e.IsGetData) 
     { 
      e.Value = person.PersonKey.Surname; 
     } 
    } 

回答

0

已解決。

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) 
     { 
      GridView gridView = (GridView)sender; 

      Person person = e.Row as Person; 
//... 
} 
相關問題