3

I have a program that contains a statusbar (ToolStripStatusLabel) which while testing one day, the program threw the "index out of range" exception and told me I could either continue or quit. I clicked continue and the status bar turned into a blank control with a red cross through it.

I think it may be related to this question here: "Red Cross" problem on MenuStrip and ToolStrip

But I don't understand the answer, nor do I really know what the cause of it was, as I really do not do anything to the status strip besides assigning the text to some error message or notice to tell the user what is going on with the program.

Any information is greatly appreciated. It happened only once but it's gonna bother me for the next while if I don't know why it did that.

I'm using .NET 3.5 SP1 C#

Community
  • 1
  • 1
tf.rz
  • 1,347
  • 6
  • 18
  • 47

1 Answers1

3

Your problem is that you cause with your unhandled IndexOutOfRangeException a corrupt state in the ToolStrip. So it can't properly draw itself.

To be safe not sorry check your code that sets something from the StatusStrip or ToolStripStatusLabel that can throw an IndexOutOfRangeException.

JYelton
  • 35,664
  • 27
  • 132
  • 191
Skomski
  • 4,827
  • 21
  • 30
  • Hello! I realized that the error is actually a cross-threading error that renders the toolstrip useless, which causes the red x situation. Do you know how I might be able to fix this? =) Thanks Skomski! – tf.rz Aug 11 '11 at 18:45
  • Sure run your code for setting stuff in the Toolstrip in the UIThread - http://msdn.microsoft.com/en-us/library/ms171728.aspx – Skomski Aug 11 '11 at 19:04