Here is my screenshot:
i already try to put all the TRY..CATCH function, but all still unable capture the error above to debug......
Eg: InitialLayou, FormLoad, InitialRow.... etc.... all i have to put, but the exceptione error still display.
The problems is, sometime it will display but sometime won't.
Expert here, any idea? PLease for help on this[:'(]
i need it urgent
This kind of error ususally means something raised an exception during the Paint event of the grid. These are pretty hard to debug.
I would suggest the following:
1) Make sure you have the latest Hot Fix.
2) Errors like this are often caused by multi-threading. If your application is using multiple threads, then you may need to check InvokeRequired and make sure you are not causing changes that go across threads without the proper marshalling.
can send the latest hotfix for me? or any idea how i trace the exception point and throw the errors above.
Since he also facing the same problems and with latest hot fix, so final answer is that we need to modify our program?
Besides that, i just want to turn it off the exception error. How can it be done?
Well, yes. If you are using multiple threads, it's your responsibility as the developer to ensure that any objects or data are properly marshalled across threads. If something on the UI thread, such as a control, tries to access an object on another thread, then it will cause a problem. The WinGrid (and most controls that I am aware of) is not safe to use with data that may be modified on another thread, because the grid could attempt to access the data source at any time, such as when it is painting.
To do something like this property, what you would have to do is bind the grid to a data source that exists on the UI Thread and then use some other objects to do whatever it is you are doing on the other thread. Then you would need to marhsal the data from the other thread to the UI thread at some point.
There is no way to simply turn off the exception.
I am facing the same issue. BUT I dont know ifWinGrid maybe doing the right thing. I am using this same approach on DataGridView and there are absolutely no exceptions thrown. I dont know why WinGrid should...
Approach:
The datatable is created on UI thread
the wingrid is bound to a BindingSource (windows contrl) which wraps this datatable (also on UI thread)
Data is loaded in background thread
- before loading the bindingcontrol.raisebindinglist event is set to false
- data row is inserted
- a delegate is executed on UI thread which sets the event to true and resets binding. (assumin that now eevnts will be raised and grid will be loaded on UI thread.
question:
is there a flag to stop the grid to access the underlying binding in the OnPaint event
it seems datagridview does not decide to access the underlyin source at anytime except when the underlyin source talks to it. (or does it) I am not sure of internal implementation but it seems datagridview paints off a cache.
if i set data updation/insertion off in a grid control i expect the control not to talk to datasource in any other scenario.
shouldnt there be a cache which onpaint can use and make wingrid thread friendly?
does any developer have a sample of best practices to using a wingrid using worker threads. It would be great help.
Thanks,
sid
seems like there was an article on this in knowledge base. i should have seen it sooner.
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=9838
I am still curious why datagridview works and wingrid doesnt w/ the above approach
thanks
Siddhartha said:I am still curious why datagridview works and wingrid doesnt w/ the above approach
I can't say for sure. But my guess is that the UltraWinGrid has a huge amount of functionality that the DataGridView does not and so it needs to do more.
To answer your question, I don't think there is any way to turn off the grid's access to the data source. You might try something like this:
grid.BeginUpdate();
grid.SuspendRowSynchronization();
And then reverse it once the data is loaded:
grid.ResumeRowSynchronization();
grid.EndUpdate();
I'm not sure if that will work, but it might be worth a shot.
Of course, another option would be not to bind the grid at all until the data has come back.