【问题标题】:How to resize the windows form dynamically in mobile application?如何在移动应用程序中动态调整窗体大小?
【发布时间】:2011-04-22 09:25:42
【问题描述】:

我正在用 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 语句中的高度值吗?

【问题讨论】:

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


    【解决方案1】:

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

    在这种情况下,您可以将控件放入面板并调整面板大小,而不是调整表单大小。您也可以在这里使用软输入面板的方法:http://www.christec.co.nz/blog/archives/42

    调整停靠在底部的面板大小 的形式与高度相同 SIP。这会移动其他控件 也停靠在表单的底部 高于该区域所覆盖的区域 SIP。

    【讨论】:

    猜你喜欢
    • 2018-03-15
    • 2015-05-20
    • 1970-01-01
    • 2012-08-05
    • 2011-06-25
    • 2010-10-04
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    相关资源
    最近更新 更多