G
Guest
I am using VS.NET 2003 and am having an interesting issue with a Listbox control. Essentially, I have a form with a listbox on it. In the listbox doubleclick event I would like to do some processing and then close the form. However, I receive an error (Cannot access a disposed object named "ListBox".) after my doubleclick code has processed.
/* ***************************
private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
this.Close();
}
****************************/
To reproduce, create a form, drop a listbox on it, assign the doubleclick event and put "this.Close();" in the handler. Does anyone know if there is a fix to this issue? There are workarounds, best I've seen so far is:
/****************************
private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
this.BeginInvoke( new EventHandler( CloseForm ) );
}
private void CloseForm( Object sender, EventArgs e )
{
this.Close();
}
***********************************/
I think this must be an error in how the message processing is handled within the list box control itself?
Thanks,
Joe
/* ***************************
private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
this.Close();
}
****************************/
To reproduce, create a form, drop a listbox on it, assign the doubleclick event and put "this.Close();" in the handler. Does anyone know if there is a fix to this issue? There are workarounds, best I've seen so far is:
/****************************
private void listBox1_DoubleClick(object sender, System.EventArgs e)
{
this.BeginInvoke( new EventHandler( CloseForm ) );
}
private void CloseForm( Object sender, EventArgs e )
{
this.Close();
}
***********************************/
I think this must be an error in how the message processing is handled within the list box control itself?
Thanks,
Joe