.NET Controls Constructed Off-Screen Display Black

1

Posted by Cynic | Posted in .NET, Solutions to Problems, Windows | Posted on 02-01-2011

Tags:

ToolStripStatusLabel Goes BlackWhile working on Duplicate Photo Finder, I discovered a very odd thing: the ToolStripStatusLabel displays solid black if it is constructed off-screen, and it cannot be recovered. You can see in the upper-right screenshot how the labels are solid black.

I suppose that it would be possible to entirely construct a new control then replace the “old” one, but that’s a bit of a pain.

Instead, you can make certain that the form is drawn inside of the screen’s view port (on the monitor) by setting the Form.StartPosition to Manual and the Form.Location to 0, 0 (the upper left corner of the screen). i.e.

this.StartPosition = FormStartPosition.Manual

It’s better to set it in the designer though.

It’s interesting that it doesn’t affect the entire StatusStrip or the ToolStripProgressBars. Not sure why, and not too worried about it. Got the solution. Happy with that. 🙂

I spent a bit of time searching for an answer and never found one or anything remotely related. Hopefully this will help someone.