Why would the controls not show up!

A colleague of mine had a strange problem today. He had written a small UI application for a Windows Mobile Professional device with many controls. The controls contained several check boxes, text boxes, labels and buttons. When he ran the dialog using the "Run Dialog" option in Visual Studio, it showed up correctly and when the program ran on the device a strange thing happened. Some of the controls would show up and others would not.

It wasn’t random, the same set of controls showed up every time and others didn’t. The UI was divided into three sections each contained within a group box. I could imagine how strange he must have thought it to be. But it had already happened to me before. And when he asked me for help, I couldn’t help a smile (: If you had read this post carefully enough, you would have noticed a small remark on the group box that I had made. "Add these three static controls into a group box, name the group box "Process Info". Remember to create the three static text controls before creating the group box. I was trying the other way around, by creating the group box first, the text controls would not show up, they were hidden behind the group box." And that was the exact problem in this case too. He had added controls to the UI in a particular order, or rather, in no particular order. So all the controls added before the group box showed up correctly and others didn’t.



Update:

As Gato pointed out, this problem occurs because of the Tab order (also called z-order) of the individual controls. See the ‘Comments’ section below.

Leave a Reply

Your email address will not be published. Required fields are marked *