Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
NullReferenceException on expanding hierarchial data after moving column
posted

Hi,

I'm getting a null reference exception when trying to expand hierarchical data after moving a column on a xamDataGrid.  

I am calling "xamHierarchyGrid.FieldLayouts[0].Fields.Move(startIndex, moveToIndex);" to move the column.  This seems to work correctly, and the column updates and moves to the new position.  However, if I try to expand the hierarchial data by clicking on the plus icon to view the subrecords after calling this a couple of times, the program crashes with the null reference exception. 

I can expand and hide the data just fine before I move the column.  After moving the column once, sometimes it will crash when I try to expand the data, sometimes it will work, and occasionally, it will expand but no data will show up.  After moving the column 2-3 times, it will almost always crash when I attempt to expand the data.

This is the code I am calling to move the column:

int startIndex = xamSettingHierarchyGrid.FieldLayouts[0].Fields[fieldname].Index;

if (startIndex != moveToIndex)

{

    xamSettingHierarchyGrid.FieldLayouts[0].Fields.Move(startIndex, moveToIndex); 

}

This is the exception I get:

System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="Infragistics3.Wpf.DataPresenter.v8.1"
  StackTrace:
       at Infragistics.Windows.DataPresenter.FieldLayout.a.a()
       at Infragistics.Windows.DataPresenter.FieldLayout.a.b()
       at Infragistics.Windows.DataPresenter.FieldLayout.a.a(Field A_0)
       at Infragistics.Windows.DataPresenter.ExpandableFieldRecord.get_Description()
       at Infragistics.Windows.DataPresenter.RecordPresenter.GetRecordDescription()... etc.

   

Any help would be greatly appreciated, thanks.