【发布时间】:2010-10-04 21:32:45
【问题描述】:
使用 Windows Mobile 6.5 应用程序并遇到我认为会自动处理的问题。我在表单上有一个面板,并将其 AutoScroll 属性设置为 true。有一个文本框,显示焦点上的输入面板。为了测试,我将文本框放在可见面板之外以强制滚动条。单击文本框会弹出 inputpanel,在其 EnabledChanged 事件中调整面板的大小。由于将焦点设置到可见区域之外的控件会强制面板滚动(我已经对此进行了测试并且它按预期工作),我希望当面板调整大小时,它会滚动到焦点 texbox,但事实并非如此。
这是一些快速演示代码:
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
panel1.Size = this.ClientRectangle.Size;
TextBox t = new TextBox();
t.Size = new Size(100, 20);
// put it out of the panel's bounds
t.Location = new Point(10, 400);
t.GotFocus += new EventHandler(t_GotFocus);
t.LostFocus += new EventHandler(t_LostFocus);
panel1.Controls.Add(t);
t = new TextBox();
t.Size = new Size(100, 200);
t.Location = new Point(10,10);
panel1.Controls.Add(t);
}
void t_LostFocus(object sender, EventArgs e)
{
inputPanel1.Enabled = false;
}
void t_GotFocus(object sender, EventArgs e)
{
inputPanel1.Enabled = true;
}
private void inputPanel1_EnabledChanged(object sender, EventArgs e)
{
if (inputPanel1.Enabled)
panel1.Size = inputPanel1.VisibleDesktop.Size;
else
panel1.Size = this.ClientRectangle.Size;
}
}
【问题讨论】:
-
您可能想在您的问题中添加“Windows-mobile”标签,以便其他专家可以注意到这一点并为您提供帮助:)
标签: .net windows-mobile compact-framework autoscroll