-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[release/8.0] Allows DataGridView to start row/column on index 1 on Narrator #14003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/8.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Drawing; | ||
| using System.Windows.Forms.Primitives; | ||
| using Moq; | ||
| using Moq.Protected; | ||
| using static Interop; | ||
|
|
@@ -207,6 +208,7 @@ public void DataGridViewCellAccessibleObject_Name_ReturnExpected_IfDataGridViewN | |
| Assert.Equal(expected, accessibleObject.Name); | ||
| } | ||
|
|
||
| // Whether UIA row indexing is 1-based or 0-based, is controlled by the DataGridViewUIAStartRowCountAtZero switch | ||
| [WinFormsFact] | ||
| public void DataGridViewCellAccessibleObject_Name_ReturnExpected() | ||
| { | ||
|
|
@@ -218,12 +220,13 @@ public void DataGridViewCellAccessibleObject_Name_ReturnExpected() | |
| dataGridView.Rows.Add("3"); | ||
|
|
||
| AccessibleObject accessibleObject = dataGridView.Rows[2].Cells[0].AccessibilityObject; | ||
| string expected = string.Format(SR.DataGridView_AccDataGridViewCellName, column.HeaderText, 2); | ||
| string expected = string.Format(SR.DataGridView_AccDataGridViewCellName, column.HeaderText, 3); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, question: The changed behavior should be an opt in, or should it not?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, the current behavior was changed and the breaking change has been described in the official "Breaking change" document. The following test case |
||
|
|
||
| Assert.Equal(expected, accessibleObject.Name); | ||
| Assert.False(dataGridView.IsHandleCreated); | ||
| } | ||
|
|
||
| // Whether UIA row indexing is 1-based or 0-based, is controlled by the DataGridViewUIAStartRowCountAtZero switch | ||
| [WinFormsFact] | ||
| public void DataGridViewCellAccessibleObject_Name_ReturnExpected_IfOneRowHidden() | ||
| { | ||
|
|
@@ -236,12 +239,13 @@ public void DataGridViewCellAccessibleObject_Name_ReturnExpected_IfOneRowHidden( | |
| dataGridView.Rows[0].Visible = false; | ||
|
|
||
| AccessibleObject accessibleObject = dataGridView.Rows[2].Cells[0].AccessibilityObject; | ||
| string expected = string.Format(SR.DataGridView_AccDataGridViewCellName, column.HeaderText, 1); | ||
| string expected = string.Format(SR.DataGridView_AccDataGridViewCellName, column.HeaderText, 2); | ||
|
|
||
| Assert.Equal(expected, accessibleObject.Name); | ||
| Assert.False(dataGridView.IsHandleCreated); | ||
| } | ||
|
|
||
| // Whether UIA row indexing is 1-based or 0-based, is controlled by the DataGridViewUIAStartRowCountAtZero switch | ||
| [WinFormsFact] | ||
| public void DataGridViewCellAccessibleObject_Name_ReturnExpected_IfTwoRowsHidden() | ||
| { | ||
|
|
@@ -255,7 +259,7 @@ public void DataGridViewCellAccessibleObject_Name_ReturnExpected_IfTwoRowsHidden | |
| dataGridView.Rows[1].Visible = false; | ||
|
|
||
| AccessibleObject accessibleObject = dataGridView.Rows[2].Cells[0].AccessibilityObject; | ||
| string expected = string.Format(SR.DataGridView_AccDataGridViewCellName, column.HeaderText, 0); | ||
| string expected = string.Format(SR.DataGridView_AccDataGridViewCellName, column.HeaderText, 1); | ||
|
|
||
| Assert.Equal(expected, accessibleObject.Name); | ||
| Assert.False(dataGridView.IsHandleCreated); | ||
|
|
@@ -1432,6 +1436,23 @@ private DataGridView CreateDataGridView(int columnCount, bool createControl = tr | |
| return dataGridView; | ||
| } | ||
|
|
||
| // Unit test for https://github.com/dotnet/winforms/issues/7154 | ||
| [WinFormsFact] | ||
| public void DataGridView_SwitchConfigured_AdjustsCellRowStartIndices() | ||
| { | ||
| LocalAppContextSwitches.SetDataGridViewUIAStartRowCountAtZero(true); | ||
|
|
||
| using DataGridView dataGridView = new(); | ||
| dataGridView.Columns.Add(new DataGridViewTextBoxColumn()); | ||
| dataGridView.Rows.Add(new DataGridViewRow()); | ||
|
|
||
| Assert.Equal($"{string.Format(SR.DataGridView_AccRowName, 0)}, Not sorted.", dataGridView.Rows[0].Cells[0].AccessibilityObject.Name); | ||
|
|
||
| LocalAppContextSwitches.SetDataGridViewUIAStartRowCountAtZero(false); | ||
|
|
||
| Assert.Equal($"{string.Format(SR.DataGridView_AccRowName, 1)}, Not sorted.", dataGridView.Rows[0].Cells[0].AccessibilityObject.Name); | ||
| } | ||
|
|
||
| private class SubDataGridViewCell : DataGridViewCell | ||
| { | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this in a hot path, so this is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't affect the functionality of this switch, it was added simply to maintain consistency with other properties.