我正在用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语句中的高度值发生变化吗?
答案 0 :(得分:2)
在WinMobile应用程序中修改表单大小可能很棘手,如果不是绝对必要,我宁愿避免使用它。
在这种情况下,您可以将控件放入面板并调整面板大小,而不是调整表单大小。您还可以使用此方法在此处使用软输入面板:http://www.christec.co.nz/blog/archives/42
调整停靠在底部的面板的大小 形状与高度相同 SIP。这会移动其他控件 也停靠在表格的底部 高于该覆盖的区域 SIP。