Skip to content

Commit

Permalink
fix [Accessibility] Accessibility Insights tool keeps loading when mo…
Browse files Browse the repository at this point in the history
…use-over DataGridView dotnet#10343 (dotnet#10372)
  • Loading branch information
Epica3055 authored Dec 13, 2023
1 parent f2dd16a commit 7dd6544
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/System.Windows.Forms/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*REMOVED*virtual System.Windows.Forms.Control.ControlCollection.AddRange(System.Windows.Forms.Control![]! controls) -> void
*REMOVED*virtual System.Windows.Forms.ListView.ColumnHeaderCollection.AddRange(System.Windows.Forms.ColumnHeader![]! values) -> void
*REMOVED*virtual System.Windows.Forms.TreeNodeCollection.AddRange(System.Windows.Forms.TreeNode![]! nodes) -> void
*REMOVED*override System.Windows.Forms.DataGridViewTextBoxEditingControl.OnHandleCreated(System.EventArgs! e) -> void
*REMOVED*override System.Windows.Forms.DataGridViewComboBoxEditingControl.OnHandleCreated(System.EventArgs! e) -> void
System.Windows.Forms.AutoCompleteStringCollection.AddRange(params string![]! value) -> void
System.Windows.Forms.ComboBox.ObjectCollection.AddRange(params object![]! items) -> void
System.Windows.Forms.ImageList.ImageCollection.AddRange(params System.Drawing.Image![]! images) -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ public DataGridViewComboBoxEditingControl() : base()
TabStop = false;
}

protected override AccessibleObject CreateAccessibilityInstance() =>
new DataGridViewComboBoxEditingControlAccessibleObject(this);

// IDataGridViewEditingControl interface implementation
protected override AccessibleObject CreateAccessibilityInstance()
{
var controlAccessibleObject = new DataGridViewComboBoxEditingControlAccessibleObject(this);
_dataGridView?.SetAccessibleObjectParent(controlAccessibleObject);
return controlAccessibleObject;
}

public virtual DataGridView? EditingControlDataGridView
{
Expand Down Expand Up @@ -124,17 +126,6 @@ protected override void OnSelectedIndexChanged(EventArgs e)
}
}

protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);

// The null-check was added as a fix for a https://github.com/dotnet/winforms/issues/2138
if (_dataGridView?.IsAccessibilityObjectCreated == true)
{
_dataGridView.SetAccessibleObjectParent(AccessibilityObject);
}
}

internal override void ReleaseUiaProvider(HWND handle)
{
if (TryGetAccessibilityObject(out AccessibleObject? accessibleObject))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public DataGridViewTextBoxEditingControl() : base()
}

protected override AccessibleObject CreateAccessibilityInstance()
=> new DataGridViewTextBoxEditingControlAccessibleObject(this);
{
var controlAccessibleObject = new DataGridViewTextBoxEditingControlAccessibleObject(this);
_dataGridView?.SetAccessibleObjectParent(controlAccessibleObject);
return controlAccessibleObject;
}

public virtual DataGridView? EditingControlDataGridView
{
Expand Down Expand Up @@ -309,15 +313,4 @@ private static HorizontalAlignment TranslateAlignment(DataGridViewContentAlignme
return HorizontalAlignment.Left;
}
}

protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);

// The null-check was added as a fix for a https://github.com/dotnet/winforms/issues/2138
if (IsHandleCreated && _dataGridView?.IsAccessibilityObjectCreated == true)
{
_dataGridView.SetAccessibleObjectParent(AccessibilityObject);
}
}
}

0 comments on commit 7dd6544

Please sign in to comment.