1
我正在用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語句中的高度值得到改變?
關於該主題的另一個鏈接:http://stackoverflow.com/questions/2266518/how-to-automatically-resize-a-windows-mobile-application-when-the-keyboard-appear – Yakimych 2010-10-07 14:18:52