pbean
pbean

Reputation: 717

How to automatically resize a Windows Mobile application when the keyboard appears?

I'm looking into Windows Mobile development but there is one thing which I haven't quite figured out yet. In all applications already installed on the device (Internet Explorer, configuration windows, etc) whenever the on-screen (soft?) keyboard appears, the user interface automatically resizes so the keyboard doesn't cover or obscure the user interface (and if necessary it adds scroll bars).

However when I simply add a text box to my Windows Mobile form, somewhere near the bottom, and test it, it's not automatically resized. The keyboard covers the text box and I can no longer see what I am typing.

Is there a way to automatically do this, or should I do this myself using an InputPanel control and listening for its event?

This is all with .NET (the compact framework, I believe), C# and Windows Mobile Professional 6.1, by the way.

Upvotes: 1

Views: 4437

Answers (2)

Thorsten Dittmar
Thorsten Dittmar

Reputation: 56727

You will have to set the Anchor property for the control respectively. The form will be resized automatically because it is full-screen, but unless you tell your control to be anchored to the bottom, it will not move but be "outside" the form.

Example: You have a "fill client area" ListView and two buttons below that ListView. To make the ListView adjust its size and move the buttons according to the new height, set the ListView's anchor property to "Top, Left, Bottom, Right" and the buttons` anchor property to "Bottom, Left" and "Bottom, Right". That way you also account for screen rotation in that the controls resize/move correctly.

You'd have to listen to the InputPanel events only in case you want to entirely restructure your layout when the SIP is shown/hidden.

Upvotes: 1

Rhapsody
Rhapsody

Reputation: 6077

Use the InputPanel component. It contains a EnabledChanged event. Simply handle the event and resize/hide/show your controls. :)

Example code can be found at the MSDN.

Upvotes: 2

Related Questions