views:

54

answers:

1

I am developing mobile application in C#. I am using the keyboard launch functionality to launch the keyboard on mobile device when one of the textbox gets focused. I am using the following code.

private void inputPanel1_EnabledChanged(object sender, EventArgs e)
        {
            InputEnabled();
        }

        private void InputEnabled()
        {
            int y;

            if (inputPanel1.Enabled)
                // SIP visible - position label just above the area covered by the input panel  
                y = Height - inputPanel1.Bounds.Height;
            else
                // SIP not visible - position label just above bottom of form
                y = Height;

            // Calculate the position of the top of the label
            //y = y - mainPanel.Height;
            //this.Dock = DockStyle.Top;
            //mainPanel.Location = new Point(0, y);
            this.Size = new Size(this.Size.Width, y);
            this.AutoScroll = true;

            //this.AutoScrollPosition = new Point(this.AutoScrollPosition.X, descriptionTextBox.Location.Y);
        }

In the above code I am trying to change the height of windows form dynamically. I have added breakpoint in my application. In the following statement

this.Size = new Size(this.Size.Width, y);

I can see the value of y gets changed to 180 in right side. But in the left side the value of this this.Size remains unchanged. I am totally unaware why this is happening. Can you please tell me is anything wrong in my code or can you provide me the solution so that the value of height in the this.size statement on the left side gets changed ?

+1  A: 

Modifying the form size in a WinMobile application could be tricky and I would rather avoid it if not absolutely necessary.

In this case, instead of resizing the form you can place your controls into a panel and resize the panel. You can also use the approach for using a soft input panel here: http://www.christec.co.nz/blog/archives/42

Resize the panel docked to the bottom of the form to be the same height as the SIP. This moves other controls also docked to the bottom of the form to be above the area covered by the SIP.

Yakimych
And another link on the topic: http://stackoverflow.com/questions/2266518/how-to-automatically-resize-a-windows-mobile-application-when-the-keyboard-appear
Yakimych