mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-15 17:10:51 -10:00
[Windows.Forms] DataGridViewTextBoxCell: do not use a shared editing control
This fixes the case of the System.ObjectDisposedException being thrown when editing a text cell in a DataGridView control a second time. The problem is that the static control would be disposed by the code in DataGridView's EditingControlInternal, but this instance was reused over and over. Instead, we now createa new editing control every time that the TextBoxCell is created. The investigation for this bug took place here: https://bugzilla.xamarin.com/show_bug.cgi?id=9653 Fixes also: https://bugzilla.xamarin.com/show_bug.cgi?id=22297
This commit is contained in:
1 parent
43aa9be05d
commit
a080a7d8a9
1 file changed
+10
-9
@@ -33,13 +33,16 @@ namespace System.Windows.Forms {
|
||||
public class DataGridViewTextBoxCell : DataGridViewCell {
|
||||
|
||||
private int maxInputLength = 32767;
|
||||
private static DataGridViewTextBoxEditingControl editingControl;
|
||||
private DataGridViewTextBoxEditingControl editingControl;
|
||||
|
||||
static DataGridViewTextBoxCell ()
|
||||
void CreateEditingControl ()
|
||||
{
|
||||
editingControl = new DataGridViewTextBoxEditingControl();
|
||||
editingControl.Multiline = false;
|
||||
editingControl.BorderStyle = BorderStyle.None;
|
||||
editingControl = new DataGridViewTextBoxEditingControl() {
|
||||
EditingControlDataGridView = DataGridView,
|
||||
Multiline = false,
|
||||
BorderStyle = BorderStyle.None,
|
||||
MaxLength = maxInputLength
|
||||
};
|
||||
}
|
||||
|
||||
public DataGridViewTextBoxCell ()
|
||||
@@ -88,12 +91,10 @@ namespace System.Windows.Forms {
|
||||
if (DataGridView == null) {
|
||||
throw new InvalidOperationException("There is no associated DataGridView.");
|
||||
}
|
||||
|
||||
|
||||
CreateEditingControl ();
|
||||
DataGridView.EditingControlInternal = editingControl;
|
||||
|
||||
editingControl.EditingControlDataGridView = DataGridView;
|
||||
editingControl.MaxLength = maxInputLength;
|
||||
|
||||
if (initialFormattedValue == null || initialFormattedValue.ToString () == string.Empty)
|
||||
editingControl.Text = string.Empty;
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user