[Mono-dev] Patches for mono-winforms

Steven Boswell II ulatekh at yahoo.com
Tue Aug 7 01:32:00 UTC 2012


https://github.com/mono/mono/commit/ecef298bcaf571a3d50e022318b20117f9d0388c introduced another bug that I found today.  Enclosed is the fix.


DataGridViewTextBoxCell was creating a single (as in static) instance of DataGridViewTextBoxEditingControl to do all editing.  This fails if one edits two text-box cells, because ending the first edit calls Dispose() on the static instance, and the second attempt to edit throws an ObjectDisposedException.

The solution is to use the control created by DataGridView, instead of maintaining a single static control.

Incidentally, this also fixes a bug that I hadn't yet taken the time to track down.  http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.editingcontrolshowing.aspx mentions that DataGridView reuses the editing control whenever the cell type does not change between edits, and so any event-handlers placed on the control during the EditingControlShowing event should be removed.  For this to work, control reuse could not be across multiple instances of DataGridView -- the event-handlers put onto editing-controls by other DataGridView instances would be unknowable.  The previous static-instance code had this flaw; I noticed that event-handlers seemed to accumulate on text-box editing controls across data-grid-views when using Mono, even though I was following the recommended procedure, and that it wasn't happening under .NET and MS Windows.  But no one would have noticed this
 until https://github.com/mono/mono/commit/f9bea537f1ac41753f2204b8528a6292bb547111 (about 2 months ago), when the EditingControlShowing event was posted for the first time. :-)

Steven Boswell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120806/0625bc6d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mwf-20-DataGridViewTextBoxCell-InitializeEditingControl.patch
Type: application/octet-stream
Size: 1403 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120806/0625bc6d/attachment.obj>


More information about the Mono-devel-list mailing list