3

Sometimes an XtraGrid gets a red cross instead of data. ( http://www.devexpress.com/Support/Center/p/CB4246.aspx , http://www.devexpress.com/Support/Center/p/A884.aspx and so on )

I have enabled to break on exceptions (Ctrl+D, E, selected all exceptions) - but am not sure if anything else can happen so that the red corss comes.

Is there an easy way if you are in the state "XtraGrid shows red X" that the XtraGrid can get to work again (as far as i seen only closing a form and reopening it helped).

I'm searchign for something like

 GridView gridView = this. GridViewXYZ(objectview);
 // objectView is refreshed
 gridView.RefreshData(); // <- this can thorw an exception that data is not available / UI will get an red cross
 // ??? do something to reset the gridView in a workig condition
Offler
  • 1,223
  • 1
  • 12
  • 34
  • Do you draw via OnPaint method? this might cause the [Red Cross error][1]. [1]: http://stackoverflow.com/questions/1000052/red-cross-problem-on-menustrip-and-toolstrip – Manuel Apr 17 '13 at 12:33
  • Can you show us the code throwing the error and the error you are getting? – Bit Apr 18 '13 at 01:50
  • @AlwaysLearning It is not about the code throwing an error. Most cases where an error is thrown and known the state before the error could be repaired. It is about the state when the error already appeared. It could always happen (equally how good you test a program) that aproblem only appears at a customer. The customer should not be bothered with spontanous red crossed elements, which only disappear by some voodoo. SO a way is searched to recover from an error state. A pattern like 'if "error" then log "error" undo "last action" – Offler Apr 19 '13 at 05:59
  • @Offer I don’t thinks it voodoo, I think the customer has an out of date DLL or the program is trying to load data to the GUI from a tread outside it native thread. It is always about the error. – Bit Apr 20 '13 at 00:36
  • Let me explain what i mean with voodoo. If something happens so that a red coss appears it is black magic for a customer what to do do do further work. Also It is not clear if there ar eother reasons then the well known one that a red cross appears. Maybe its time to override the complete crap of the internal error handling of the XtraGrid. If something is not there thre should not be a red cross - a handable exeptino -o.k. Some rows explaining that their data can not be shown - also o.k. Red Cross - just crap. – Offler Apr 21 '13 at 10:06

4 Answers4

2

From my previous GDI experience once you're in this state you're stuck. You've done something that has caused a problem within GDI and it's not managed to throw an exception/recover from it.

The act of closing/re-opening the Form causes the un-managed GDI object for it to be released and re-created, and hence GDI is fully operable again, until the same error condition occurs. If you can't prevent this error, you could have a look at trying to re-create a new GDI object for the form/control but I'm not sure how you'd go about doing so.

Really this is a bug which the DevExpress team should probably solve.

Ian
  • 33,605
  • 26
  • 118
  • 198
2

You could try to call BeginInvoke on the Grid.

Action a = () => gridView.RefreshData();
gridView.GridControl.BeginInvoke(a);

Whenever fiddeling with the datasource, you could try wrapping it in a statement like this.

I have expirensed something simular, and you be supprised how often some like this works.

Jens Kloster
  • 11,099
  • 5
  • 40
  • 54
  • REfreshData() has a type void. If I try your solution I only get: an implicit conversion from type "void" to Action is not possible. – Offler Apr 19 '13 at 06:11
  • But shouldn't an Action point to a method which returns void? the devexpress thingy is 'public override void RefreshData(); ' – Offler Apr 19 '13 at 06:21
  • Yes you are right - I updated the answer. My syntax was wrong -sry – Jens Kloster Apr 19 '13 at 06:27
  • I'm curious if it helps, as there is no "InvokeRequired" as the datagrid refresh is especially done in ui thread. Give it a try with a known issue. – Offler Apr 19 '13 at 06:35
  • With this the behaviour stays the same – Offler Apr 19 '13 at 06:48
  • is `gridView.RefreshData` the place where the error orccures? Debug as far as you can, and when the error orccures, wrap the last code block in a function like the above. – Jens Kloster Apr 19 '13 at 06:55
  • it is the last place. The block only contains all gridviews which need to be refrehed and does call refresh. – Offler Apr 19 '13 at 07:35
  • Im not sure if RefreshData needs to be called. Start by not calling it. Wrap the hole code block in the action `Action a = ()=>{ /*multible lines*/ };` - see if it works – Jens Kloster Apr 19 '13 at 08:04
  • As noted in Devexpress forms this will not help with this issue. – Bit Apr 20 '13 at 00:37
1

Is there an easy way if you are in the state "XtraGrid shows red X" that the XtraGrid can get to work again

Yes if you never get into the error state in the first place. Otherwise workaround it by closing/reopening.

The article you link to has info on what causes the "Red Cross of Death" to appear, either a unhandled exception occurs during painting, you handle a control's CustomDraw event and an exception occurs or methods are being called asynchronously.

If you have difficulty in determining the cause of the problem, please try to recreate the issue in a sample project and send it to the DevExpress Support Team.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • The bad thing is that the unhandled exception can be somewhere much deepte in the XtraGrid itself. Therefore its not an answer how to get it back to live. If you read about the XtraGrids even change of the data in DataSource can cause a RedX. So it just does not help to only fix known problems, its about what do do on error. If you look at answers on DevExpress site I often get the feeling that even if many peopel complain about an issue for DevExpress it is no issue (e.g. not animated gifs - workaround, DatagridSource can not be changed - don't change DataGrid Source etc.pp.) – Offler Apr 17 '13 at 14:06
  • 1
    Why the downvote? If you have difficulty in determining the cause of the problem create a bare bones repro and send it to DevExpress. – Jeremy Thompson Apr 17 '13 at 22:09
  • @kenroger fro me it is not an answer. Cases where an error is thrown and known during development time, the state leading to the error could be repaired. That is NOT asked. If the grid is not so stable an error could come unexpected. Therefore the question is about the state when the error already appeared. The customer should not be bothered with spontanous red crossed elements, which only disappear by some voodoo. So a way is searched to detect/recover from an unexpected error state. A pattern like 'if "error" then log "error" undo "last action". And not one to fix known problems. – Offler Apr 19 '13 at 06:04
  • @JeremyThompson Known errors can bbe fixed. The question is for detecting/ fixing the problem in error state. Therefore the answer missed the topic of the question. The question is solely for the purpose: IF something unexpected happened (and known issues during development are nothing unexpected, but something which can be fixed) what can be done to recover this thing from red cross. This is the question, you haven't answered it. – Offler Apr 19 '13 at 06:07
0

Having same problem sometimes with Visusa Studio extension CodeRush (also provided by devExpress) when showing references dialog. So it seems to be a internal problem. Hope the next version of devexpress will fix the problem.

Micha
  • 5,117
  • 8
  • 34
  • 47