Reputation: 364
So, I've got a C# project for Windows Mobile phones and I'm trying to work with the InputPanel. Specifically, I've got one form with a stack of Labels and TextBoxes that collect user input. I have an InputPanel that alerts me when the user opens the SIP. Everything works fine so far. When I get messages that the SIP status has changed, I want to change the height of the Form, which doesn't seem possible.
Here's my event handler for my InputPanel:
void m_InputPanel_EnabledChanged(object sender, EventArgs e)
{
// :( this assignment operation doesn't work and it doesn't
this.ClientSize = inputPanel1.VisibleDesktop.Size;
// doesn't work
this.Size = inputPanel1.VisibleDesktop.Size;
// assignment operation works, but isn't very useful
this.visibleHeight = inputPanel1.VisibleDesktop.Height;
this.InitializeUI();
}
When I say that the assignment operation doesn't work, I mean that the values don't change in the debugger. I can understand that maybe I can't change the size of a Form, but I can't understand why trying to change it wouldn't throw an exception, or give a compiler error.
I have my Form WindowState set to Normal instead of Maximized, but it doesn't make a difference.
Also, I have read http://www.christec.co.nz/blog/archives/42 this page that tells me how I'm supposed to do this, but I can't easily put all of my controls in a Panel because I'm using a bunch of custom stuff to do alpha background controls.
Upvotes: 2
Views: 1152
Reputation: 75296
Changing the height and width of a form in .NET CF has no effect whatsoever, unless its FormBorderStyle
is set to None
.
However, doing this isn't a good idea in your case, since you don't actually want a borderless form. The proper thing to do in your case is to put all of your controls (labels and textboxes) on a Panel
(which is sitting on your form, of course), and then resize the panel as the SIP opens and closes.
Edit: Since I've seen this kind of interface in Windows Mobile, please allow me to give you some unsolicited UI advice. Rule #1 for me with .NET CF applications is: "never use the SIP under any circumstances". The SIP is, of course, completely unusable without a stylus, and not very much use with a stylus, especially with an even slightly out-of-alignment screen.
If you must break Rule #1 (and of course, you have to break this rule for most kinds of free-form text input), then your UI should at least be polite to the user and do two things:
Finally, I've generally found it easier to use static methods like this rather than adding an InputControl to each of my forms. I find InputControls to be a pain, and sometimes they get in each other's way if you have more than one form with an InputControl on it open at the same time.
Upvotes: 4