C# 如何在移动应用程序中动态调整windows窗体的大小?

C# 如何在移动应用程序中动态调整windows窗体的大小?,c#,windows,windows-mobile,compact-framework,autoresize,C#,Windows,Windows Mobile,Compact Framework,Autoresize,我正在用C#开发移动应用程序。当其中一个文本框聚焦时,我使用键盘启动功能在移动设备上启动键盘。我正在使用以下代码 private void inputPanel1_EnabledChanged(object sender, EventArgs e) { InputEnabled(); } private void InputEnabled() { int y;

我正在用C#开发移动应用程序。当其中一个文本框聚焦时,我使用键盘启动功能在移动设备上启动键盘。我正在使用以下代码

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);
        }
在上面的代码中,我试图动态更改windows窗体的高度。我在应用程序中添加了断点。在以下声明中

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

我可以看到右边y的值变为180。但在左侧,this.Size的值保持不变。我完全不知道为什么会这样。您能告诉我我的代码中有什么错误吗?或者您能提供解决方案,以便更改左侧this.size语句中的height值吗?

在WinMobile应用程序中修改表单大小可能很棘手,如果不是绝对必要,我宁愿避免

在这种情况下,您可以将控件放入面板中并调整面板大小,而不是调整窗体大小。您也可以在此处使用软输入面板的方法:

调整固定到底部的面板的大小 形状的高度应与 啜一口。这将移动其他控件 也停靠在表单的底部 位于该区域所覆盖的区域之上 啜饮


以及关于该主题的另一个链接: