![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | ObjectDisposedException on second use I have created a DataGridViewNumericUpDownColumn using this from MSDN: http://msdn.microsoft.com/en-us/libr...81(vs.80).aspx I build my grids at run-time, here is the code for adding the column: Dim colQtyShipped As New DataGridViewNumericUpDownColumn With colQtyShipped .Increment = 1 .Minimum = 0 .Maximum = 250 .DataPropertyName = "QuantityShipped" .AutoSizeMode = DataGridViewAutoSizeColumnMode.None .HeaderText = "Packed" .Name = "QuantityShipped" .[ReadOnly] = False .Visible = True .MinimumWidth = 50 .Width = 50 End With itemGrid.Columns.Add(colQtyShipped) The first time i open a form, all works well. The column displays, the arrows work fine, the data binding works fine. As soon as i close the form and open a new instance, I get this error: Cannot access a disposed object Object name: 'NumericUpDown'. System.ObjectDisposedException was unhandled by user code Message="Cannot access a disposed object.\r\nObject name: 'NumericUpDown'." Source="System.Windows.Forms" ObjectName="NumericUpDown" StackTrace: at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.ControlCollection.Add(Control value) at System.Windows.Forms.Control.set_ParentInternal(Control value) at System.Windows.Forms.Control.set_Parent(Control value) at DataGridViewNumericUpDownElements.DataGridViewNumericUpDownCell.Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object value, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) in C:\Dotnet\Examples \DataGridViewNumericUpDown\DataGridViewNumericUpDownElements \DataGridViewNumericUpDownCell.cs:line 575 at System.Windows.Forms.DataGridViewCell.PaintInternal(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, Object value, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) at System.Windows.Forms.DataGridViewCellPaintingEventArgs.PaintContent(Rectangle clipBounds) at ComponentFactory.Krypton.Toolkit.KryptonDataGridView.OnCellPainting(DataGridViewCellPaintingEventArgs e) at System.Windows.Forms.DataGridViewCell.PaintWork(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) at System.Windows.Forms.DataGridViewRow.PaintCells(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts) at System.Windows.Forms.DataGridViewRow.Paint(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow) at System.Windows.Forms.DataGridView.PaintRows(Graphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdded) at System.Windows.Forms.DataGridView.PaintGrid(Graphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdded) at System.Windows.Forms.DataGridView.OnPaint(PaintEventArgs e) It points to this line of code paintingNumericUpDown.TextAlign = DataGridViewNumericUpDownCell.TranslateAlignment(cellStyle.Alignment); in class DataGridViewNumericUpDownCell Really not sure what is causing this. i am not trying to reuse an object, trying to create a new one. |
My System Specs![]() |