TabControl, TabPage, Screen Rotation and Compact Framework#

Was taking a look at a screen rotation (portrait to landscape and back) issue we were having in one of our soon to be released products when using the TabControl/TabPage.Height property and Compact Framework 2.0 and Windows Mobile 5.0.

When the screen orientation changed, the Form.Resize event is raised.  Great, easy enough to adjust some ListViews that are in the TabPage using the following code:

listView2.Height = listView1.Height = (tabControl1.TabPages[0].Height / 2) - 2;

Although you think it would work, it doesn't because the TabPages[0].Height property is the Height before the Screen rotation occurs.

To work around this is easy enough, just use the Form.Height properties.

listView1.Height = listView2.Height = (this.Height - (20 * m_scale)) / 2;

where

  • 20 is the height of the tabs
  • m_scale is to support hi res devices

Download the sample code here.

UPDATE: Got a comment here about using docking and anchoring which is true but for some reason was not working properly in our application, don't know why so we resorted to manually calculating sizes.  I updated the sample code which shows the ListViews properly sizing using the Anchor property on rotation. 


Monday, January 15, 2007 9:34:46 PM (Eastern Standard Time, UTC-05:00) #    Comments [0]  | 

 

Comments are closed.
All content © 2008, Mark Arteaga
On this page
Related Sites
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts