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

标签 c# windows windows-mobile compact-framework autoresize

我正在用 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);
        }

在上面的代码中,我试图动态地改变窗体的高度。我在我的应用程序中添加了断点。在下面的声明中

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

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

最佳答案

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

在这种情况下,您可以将控件放入面板并调整面板大小,而不是调整窗体大小。您还可以在此处使用软输入面板的方法: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.

关于c# - 如何在移动应用程序中动态调整窗口窗体的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3882340/

相关文章:

c# - 无法在具有十进制绑定(bind)的文本框中输入 "."

c# - Entity Framework Core 从现有数据库创建模型

c# - 获取子进程的形式

C#:退出应用程序的非 Winforms 方式?

c++ - 使用 IOCTL_CHANGER_GET_PRODUCT_DATA 调用 DeviceIoControl 时出现 ERROR_ACCESS_DENIED

.net - 如何让移动应用保持领先?

c# - 获取从url发送到wpf的变量?

c - 如何检测进程是否作为服务安装

c# - .NET Compact Framework 打印库

c++ - 使用 IAMCameraControl::Set() 在 Windows Mobile 设备上设置缩放