I can cause an unhandled ArgumentException if I select a band in the Column Chooser dialog of a grid that has been disposed and released from memory.
Why doesn't the grid close the Column Chooser when the grid's Dispose() method is called?
How can I force the grid to close the Column Chooser?
System.ArgumentException:
CurrentBand must be a valid band from the SourceGrid.
Parameter name: CurrentBand
Exception Properties:
ParamName: CurrentBand
Stack Trace:
at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.set_CurrentBand(UltraGridBand value)
at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.comboBoxBandSelector_SelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Jeffrey,
CAS-89247-XQWFDJ has been opened for you. The issue has been submitted to development for further review. You will receive more information through the support case.
Thanks for the quick turn around on that one Mike. I'll add your work-around to my to-do list.
jb
Hi,
I tried this out and I get the same results you describe. Disposing the grid does not close the dialog. That appears to be a bug, so I am going to forward this thread over to Infragistics Developer Support and ask them to create a case for you and write this issue up for developer review so we can get it fixed.
In the mean time, you can work around this pretty easily by keeping a reference to the dialog and disposing it yourself when the grid is disposed:
ColumnChooserDialog columnChooserDialog; private void ultraGrid1_BeforeColumnChooserDisplayed(object sender, BeforeColumnChooserDisplayedEventArgs e) { this.columnChooserDialog = e.Dialog; this.ultraGrid1.Disposed += new EventHandler(ultraGrid1_Disposed); } void ultraGrid1_Disposed(object sender, EventArgs e) { if (this.columnChooserDialog != null) { this.columnChooserDialog.Close(); this.columnChooserDialog.Dispose(); this.columnChooserDialog = null; } }
ColumnChooserDialog columnChooserDialog;
private void ultraGrid1_BeforeColumnChooserDisplayed(object sender, BeforeColumnChooserDisplayedEventArgs e) { this.columnChooserDialog = e.Dialog; this.ultraGrid1.Disposed += new EventHandler(ultraGrid1_Disposed); } void ultraGrid1_Disposed(object sender, EventArgs e) { if (this.columnChooserDialog != null) { this.columnChooserDialog.Close(); this.columnChooserDialog.Dispose(); this.columnChooserDialog = null; } }