My main form contains a panel which I use to host user controls
After I have added and then removed all instances of my user controls from the panel, then move focus away from and back to my app, my main form appears disabled

Is there something I need to be doing in my user control? If I use a standard control e.g. Button I don't get the problem
A simplified version of my code is shown below

using System
using System.Windows.Forms

namespace WindowsApplication

public class MyControl: UserContro

public MyControl(

this.Controls.Add(new Button())



public class Form1 : For

private Panel PanelMain
private MyControl t1

public Form1(

MenuItem menuAdd = new MenuItem("&Add",new System.EventHandler(this.Add_Click))
MenuItem menuRemove = new MenuItem("&Remove",new System.EventHandler(this.Remove_Click))
this.Menu = new MainMenu(new MenuItem[]{menuAdd,menuRemove})

PanelMain = new Panel()
t1 = new MyControl()

this.Controls.Add(PanelMain)


[STAThread
static void Main()

Application.Run(new Form1())


private void Add_Click(object sender, System.EventArgs e

this.PanelMain.Controls.Add(t1)
t1.Focus()


private void Remove_Click(object sender, System.EventArgs e

this.PanelMain.Controls.Remove(t1);

Re: user control host form gets disabled by richlm

richlm
Tue Jun 08 01:50:30 CDT 2004

Turns out to be a known bug. There's a hot fix available from Microsoft
product support - see
http://support.microsoft.com/default.aspx?scid=kb;en-us;827534

"richlm" <rich_lm@h0tmai1.com> wrote in message
news:14453C1F-5D27-4072-B5A5-FC6BF890C2E7@microsoft.com...
> My main form contains a panel which I use to host user controls.
> After I have added and then removed all instances of my user controls from
the panel, then move focus away from and back to my app, my main form
appears disabled.
>
> Is there something I need to be doing in my user control? If I use a
standard control e.g. Button I don't get the problem.
> A simplified version of my code is shown below:
>
>
> using System;
> using System.Windows.Forms;
>
> namespace WindowsApplication9
> {
> public class MyControl: UserControl
> {
> public MyControl()
> {
> this.Controls.Add(new Button());
> }
> }
>
> public class Form1 : Form
> {
> private Panel PanelMain;
> private MyControl t1;
>
> public Form1()
> {
> MenuItem menuAdd = new MenuItem("&Add",new
System.EventHandler(this.Add_Click));
> MenuItem menuRemove = new MenuItem("&Remove",new
System.EventHandler(this.Remove_Click));
> this.Menu = new MainMenu(new MenuItem[]{menuAdd,menuRemove});
>
> PanelMain = new Panel();
> t1 = new MyControl();
>
> this.Controls.Add(PanelMain);
> }
>
> [STAThread]
> static void Main()
> {
> Application.Run(new Form1());
> }
>
> private void Add_Click(object sender, System.EventArgs e)
> {
> this.PanelMain.Controls.Add(t1);
> t1.Focus();
> }
>
> private void Remove_Click(object sender, System.EventArgs e)
> {
> this.PanelMain.Controls.Remove(t1);
> }
> }
> }
>