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
760
Columns.Add throws an exception
posted

We are using 11.1..

In our GUI, when the user refreshed data on the grid, we call 

xamGrid.Columns.Clear

and then do something like this...

 

 if (xamGrid.Columns[colName] == null)

                {

                    textColumn = new TextColumn();

                    textColumn.Key = colName;

                    xamGrid.Columns.Add(textColumn);

                }

 

 

We get an "Object reference not set to an instance of an object" at  the line xamGrid.Columns.Add ..

The stack trace shows this

   at Infragistics.Controls.Grids.XamGridRowsManager.InvalidateGroupBy(Boolean reset).

 

How do I get rid of this error? I verified that the column count was zero after the call to the Columns.Clear

 

Parents
No Data
Reply
  • 40030
    Offline posted

    Hi, 

    I tried the code you posted in a button click, and it worked just fine: 

    this.grid1.Columns.Clear();
    
                if (grid1.Columns["Number"] == null)
                {
                    TextColumn tc = new TextColumn();
                    tc.Key = "Number";
                    this.grid1.Columns.Add(tc);
                }
    
    What do you mean by referesh data...are you calling a method on the xamGrid or applying a new 
    itemsSource?
    
    
    Where are you adding the new columns? By that, i mean are you calling int while the xamGrid is 
    performing an operation?
    If you have a sample that shows this issue, it'd be much more helpful, and would allow me to figure 
    out the problem a lot quicker. 
    Thanks, 
    -SteveZ 

Children