【发布时间】: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