winforms
winforms copied to clipboard
Fixing memory leaks of DataGridView elements accessible objects
Fixes #7347 ⚠️Should be merged after #7319 because uses the ComboBox leaks fix. ⚠️Doesn't fix memory leaks of TextPattern. It will be fixed as another fix for TextBox as well.
Proposed changes
- Add a call of UiaDisconnectProvider for DataGridView elements (rows, cells, headers) for cases when: DataGridView is destroyed A row is removed from a DataGridView A column is removed from a DataGridView Using TextPattern explorer of Inspect, Narrator
Customer Impact
- Less memory leaks of DataGridView
Regression?
- No
Risk
- Minimal
Screenshots
Before
- There are some kept object in the memory after disposing a DataGridView:

After
- These are no DataGridView elements objects in the memory after disposing (without TextPattern):

Test methodology
- CTI
- Manually (via WinDbg)
Accessibility testing
- Using AI, Inspect, Narrator
Test environment(s)
- .NET 7.0 Preview 4
- Windows 11