.NET Compact Framework inputPanel1.Enabled error

If you are trying to automatically show an Input Panel in a Compact Framework windows application in the InitializeComponent() method, you will likely get this runtime error in .NET 1.1 Framework.

If you are trying to automatically show an Input Panel in a Compact Framework windows application in the InitializeComponent() method, you will likely get this runtime error in .NET 1.1 Framework.


If you are trying to automatically show an Input Panel in a Compact Framework windows application in the InitializeComponent() method, you will likely get this runtime error in .NET 1.1 Framework.

An unhandled exception of type 'System.Exception' occurred in Microsoft.WindowsCE.Forms.dll

This appears to either be a bug or a problem with initialization of the panel prior to the complete initialization of the form.

In order to make this work, simply create a _GotFocus event for another control on the form such as a textbox or command button. In the InitializeCompnent method, call .Focus() on that control.

public Form1()
{
InitializeComponent();
this.txtText.Focus();
}

private void InitializeComponent()
{
this.txtText.GotFocus += new System.EventHandler(this.txtText_GotFocus);
}

In the control _GotFocus event, set the input panel enabled property to true.

private void txtText_GotFocus(object sender, System.EventArgs e)
{
this.inputPanel1.Enabled = true;
}

By Robbe Morris   Popularity  (659 Views)
Picture
Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of NullSkull.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.  Robbe also loves to scuba dive and go deep sea fishing in the Florida Keys or off the coast of Daytona Beach. Microsoft MVP