Although the answer to this question is an exact duplicate, the problem I encountered (and therefore the question itself) is not an exact duplicate. In searching for possible answers, I would not recognize the referenced question as being likely to contain the answer to my problem.
I am drawing waveforms on a panel by overriding OnPaint for the control. Everything works fine at runtime. However, when I am in the designer, if I move my cursor over the panels, an IndexOutOfRange exception is raised and the panel shows the error:
Of course the errors are correct, because ALL the indexes are out of bounds when the program isn't running.
The behavior is merely annoying, but I would like to understand how to control it. I am guessing there is some straightforward way to tell when the panel is being displayed in the design environment or alternatively to tell when it is being displayed in the executing application environment. If so, I can add logic to the overridden OnPaint to handle this situation.
I've searched Stack Exchange and googled extensively and looked in all my reference books, but I have not found any explanation of how I can distinguish between the design-time and run-time environment. Perhaps I just have not found the right descriptive vocabulary?