Hi,
I am getting the following error while setting the datasouce of the Wingrid. The error is sporadic. The data source is a list of business objects.
The line of code is : grid.DataSource = dataSouce;
The error seems to occur when the grid is bound to a list of objects and I try to rebind the grid with a new list of objects (typically I need to do this when there is a new item to be added to the list).
When I inspect this list (of business objects), everything looks okay. None of the objects themselves are null.
I would appreciate any help. Thanks.
System.NullReferenceException was unhandled
StackTrace:
at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)
at Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource(Object value)
at PortfolioMonitor.UserControls.ObjectGrid.BindGrid(IGridDataBroker obj, UltraGrid grid) in C:\..............
The onlything that springs to mind is that perhaps you are using multiple threads in your application and the data is not getting properly marshalled to the UI Thread? Is your app using multiple threads?
For me solution was
((System.ComponentModel.ISupportInitialize)(grid)).BeginInit(); Grid.DataSource = value; ((System.ComponentModel.ISupportInitialize)(grid)).EndInit();
Actually, I did finally figure out my issue. The timer that I was using was a System.Timers.Timer, not a Windows.Forms.Timer. The timer that I was using works on a separate thread, not the main thread as a Windows.Forms.Timer does. When I changed out the variety of timer, I was golden!
rammam said: I'm not sure if you have figured this out yet, but I ran into something very similar yesterday and it turned out to be that the Grid had been disposed (It was on a form that had been disposed but hadn't properly released from memory due to other issues.) So you may want to check that, perhaps you have the same issue I ran into. Regards, - Aaron.
I'm not sure if you have figured this out yet, but I ran into something very similar yesterday and it turned out to be that the Grid had been disposed (It was on a form that had been disposed but hadn't properly released from memory due to other issues.)
So you may want to check that, perhaps you have the same issue I ran into.
Regards,
- Aaron.
I have just found this exact issue in our code - thanks for this solution, works great.
I'm not sure about the grid's themselves sharing resources.There are certainly shared, static method and resources used by all grids for localized strings and default colors and such.
But it's not just the grid you have to worry about, it's also the DotNet BindingManager and BindingContexts.