我正在开发C#中的移动应用程序。当Textbox集中时,我使用键盘启动功能在移动设备上启动键盘。我正在使用以下代码。

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。但是在左侧,这个值的值保持不变。我完全没有意识到为什么会发生这种情况。您能告诉我我的代码中有什么错,还是可以为我提供解决方案,以便更改左侧的尺寸语句中的高度值?

有帮助吗?

解决方案

修改Winmobile应用程序中的形式大小可能很棘手,如果不是绝对必要的话,我宁愿避免使用它。

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

调整对接到表单底部的面板的大小,为与SIP相同的高度。这将移动其他控件,也停靠到表格的底部,以使SIP覆盖的区域上方。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top