diff --git a/src/System.Windows.Forms/Resources/SR.resx b/src/System.Windows.Forms/Resources/SR.resx
index 53d5073b748..444c6752e9b 100644
--- a/src/System.Windows.Forms/Resources/SR.resx
+++ b/src/System.Windows.Forms/Resources/SR.resx
@@ -606,6 +606,15 @@
Occurs whenever the CheckState property is changed.
+
+ checked
+
+
+ unchecked
+
+
+ indeterminate
+
Indicates whether the CheckBox will allow three check states rather than two.
@@ -7045,4 +7054,4 @@ Stack trace where the illegal operation occurred was:
The FormScreenCaptureMode property can only be changed on top-level Forms with their TopLevel property set to true.
-
\ No newline at end of file
+
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms/Resources/xlf/SR.cs.xlf
index ce2bc9260f9..6789f68b587 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.cs.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.cs.xlf
@@ -907,6 +907,16 @@
Určuje, zda je součást v zaškrtnutém stavu.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Událost aktivovaná při změně hodnoty vlastnosti Appearance prvku CheckBox
@@ -927,6 +937,11 @@
Určuje, zda prvek CheckBox umožňuje tři stavy zaškrtnutí místo dvou.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Určuje, zda by po prvním kliknutí na položku mělo být zaškrtávací políčko přepnuto.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms/Resources/xlf/SR.de.xlf
index b5cf47b1170..49068c57595 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.de.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.de.xlf
@@ -907,6 +907,16 @@
Gibt an, ob sich die Komponente im aktivierten Zustand befindet.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Das ausgelöste Ereignis, wenn der Wert der Appearance-Eigenschaft für CheckBox geändert wird.
@@ -927,6 +937,11 @@
Gibt an, ob CheckBox drei statt zwei aktivierte Zustände zulässt.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Gibt an, ob der Aktivierungszustand des Kontrollkästchens mit dem ersten Klicken auf ein Element gewechselt wird.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms/Resources/xlf/SR.es.xlf
index 82eb0cd40bb..77371948c0f 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.es.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.es.xlf
@@ -907,6 +907,16 @@
Indica si el componente se encuentra en el estado de activación.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Evento que se desencadena cuando se cambia el valor de la propiedad Appearance de CheckBox.
@@ -927,6 +937,11 @@
Indica si CheckBox permitirá tres estados de activación en lugar de dos.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Indica si la casilla debe cambiar su estado al hacer clic por primera vez en un elemento.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms/Resources/xlf/SR.fr.xlf
index f02c36b8e65..5c15afd1165 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.fr.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.fr.xlf
@@ -907,6 +907,16 @@
Indique si le composant a un état activé.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Événement déclenché lorsque la valeur de la propriété Appearance du CheckBox est modifiée.
@@ -927,6 +937,11 @@
Indique si CheckBox autorise trois états d'activation plutôt que deux.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Indique si la case à cocher doit être activée ou désactivée lors du premier clic sur un élément.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms/Resources/xlf/SR.it.xlf
index fc9f709a0be..a121fea7fae 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.it.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.it.xlf
@@ -907,6 +907,16 @@
Indica se il componente è selezionato.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Evento generato quando il valore della proprietà Appearance di CheckBox viene modificato
@@ -927,6 +937,11 @@
Indica se per il controllo CheckBox saranno disponibili tre stati di selezione anziché due.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Indica se lo stato della casella di controllo deve essere modificato la prima volta che si fa clic su una voce.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms/Resources/xlf/SR.ja.xlf
index 4511ba6cf76..b2221b830a3 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.ja.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.ja.xlf
@@ -907,6 +907,16 @@
コンポーネントがチェックされた状態かどうかを示します。
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Appearance プロパティの値が、CheckBox で変更されたときに発生するイベントです。
@@ -927,6 +937,11 @@
CheckBox が 2 つではなく 3 つのチェックされた状態を許可するかどうかを示します。
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.アイテムを最初にクリックしたときに、チェック ボックスを切り替えるかどうかを示します。
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms/Resources/xlf/SR.ko.xlf
index 2924f72aab7..96758d811ec 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.ko.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.ko.xlf
@@ -907,6 +907,16 @@
구성 요소가 선택된 상태인지 여부를 나타냅니다.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Appearance 속성 값이 CheckBox에서 변경되면 이벤트가 발생합니다.
@@ -927,6 +937,11 @@
CheckBox에 두 가지가 아닌 세 가지 선택 상태를 사용할 수 있는지 여부를 나타냅니다.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.항목을 처음 클릭할 때 확인란이 설정/해제되는지 여부를 나타냅니다.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms/Resources/xlf/SR.pl.xlf
index f86297cb7f6..02d74fc6741 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.pl.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.pl.xlf
@@ -907,6 +907,16 @@
Określa, czy składnik jest zaznaczony.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Zdarzenie wywoływane, gdy zmieni się wartość właściwości Appearance elementu CheckBox
@@ -927,6 +937,11 @@
Wskazuje, czy parametr CheckBox zezwala na trzy, a nie dwa stany zaznaczenia.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Określa, czy pole wyboru powinno być przełączane pierwszym kliknięciem elementu.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms/Resources/xlf/SR.pt-BR.xlf
index 5dcda8ac793..ded38716014 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.pt-BR.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.pt-BR.xlf
@@ -907,6 +907,16 @@
Indica se o componente está no estado de ativação.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Evento gerado quando o valor da propriedade Appearance é alterado em CheckBox.
@@ -927,6 +937,11 @@
Indica se a CheckBox permitirá três estados de seleção em vez de dois.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Indica se a caixa de seleção deve ser alternada quando um item é clicado pela primeira vez.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms/Resources/xlf/SR.ru.xlf
index 89af4e75583..388d31e42d8 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.ru.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.ru.xlf
@@ -907,6 +907,16 @@
Указывает, находится ли компонент в состоянии проверки.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Событие вызывается при изменении значения свойства Appearance для CheckBox.
@@ -927,6 +937,11 @@
Определяет, позволяет ли CheckBox использование трех состояний переключателя вместо двух.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Указывает, должен ли флажок проверки изменять состояние при первом выборе данного элемента указателем мыши.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms/Resources/xlf/SR.tr.xlf
index 9e72305a890..e9e5533db15 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.tr.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.tr.xlf
@@ -907,6 +907,16 @@
Bileşenin işaretli durumda olup olmadığını gösterir.
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.CheckBox üzerinde Appearance özelliğinin değeri değiştiğinde harekete geçirilen olay.
@@ -927,6 +937,11 @@
CheckBox'ın iki yerine üç onay durumuna izin verip vermeyeceğini gösterir.
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.Onay kutusunun durumunun öğe üzerindeki ilk tıklatma ile değişip değişmeyeceğini gösterir.
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms/Resources/xlf/SR.zh-Hans.xlf
index 6827f20269f..d23b8871c36 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.zh-Hans.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.zh-Hans.xlf
@@ -907,6 +907,16 @@
指示组件是否处于选中状态。
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.在 CheckBox 的 Appearance 属性值更改时引发的事件。
@@ -927,6 +937,11 @@
指示 CheckBox 是否会允许三种选中状态,而不是两种状态。
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.指示复选框是否应在首次单击某项时切换。
diff --git a/src/System.Windows.Forms/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms/Resources/xlf/SR.zh-Hant.xlf
index 15f5f06c126..106636aeed1 100644
--- a/src/System.Windows.Forms/Resources/xlf/SR.zh-Hant.xlf
+++ b/src/System.Windows.Forms/Resources/xlf/SR.zh-Hant.xlf
@@ -907,6 +907,16 @@
表示元件是否為已核取狀態。
+
+ checked
+ checked
+
+
+
+ indeterminate
+ indeterminate
+
+ Event raised when the value of the Appearance property is changed on CheckBox.Appearance 屬性值在 CheckBox 上變更時引發的事件。
@@ -927,6 +937,11 @@
表示 CheckBox 是否允許三種核取狀態而非兩種。
+
+ unchecked
+ unchecked
+
+ Indicates if the check box should be toggled with the first click on an item.表示第一次點選項目時,是否選取核取方塊。
diff --git a/src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/CheckBox.cs b/src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/CheckBox.cs
index 57526b2644b..352fe10807d 100644
--- a/src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/CheckBox.cs
+++ b/src/System.Windows.Forms/System/Windows/Forms/Controls/Buttons/CheckBox.cs
@@ -5,8 +5,6 @@
using System.Drawing;
using System.Windows.Forms.ButtonInternal;
using System.Windows.Forms.Layout;
-using Windows.Win32.System.Variant;
-using Windows.Win32.UI.Accessibility;
namespace System.Windows.Forms;
@@ -439,9 +437,21 @@ private void NotifyAccessibilityStateChanged()
// UIA events:
if (IsAccessibilityObjectCreated)
{
- using var nameVariant = (VARIANT)Name;
- AccessibilityObject.RaiseAutomationPropertyChangedEvent(UIA_PROPERTY_ID.UIA_NamePropertyId, nameVariant, nameVariant);
- AccessibilityObject.RaiseAutomationEvent(UIA_EVENT_ID.UIA_AutomationPropertyChangedEventId);
+ // A fix for https://github.com/dotnet/winforms/issues/14669.
+ // Unfortunately we cannot use RaiseAutomationEvent method here since the control does not respond to
+ // State messages. Use RaiseAutomationNotification instead to announce a custom notification.
+ // See https://docs.microsoft.com/dotnet/api/system.windows.forms.accessibleobject.raiseautomationnotification.
+ string notificationText = _checkState switch
+ {
+ CheckState.Checked => SR.CheckBoxCheckedNotificationText,
+ CheckState.Indeterminate => SR.CheckBoxIndeterminateNotificationText,
+ _ => SR.CheckBoxUncheckedNotificationText,
+ };
+
+ AccessibilityObject.InternalRaiseAutomationNotification(
+ Automation.AutomationNotificationKind.ActionCompleted,
+ Automation.AutomationNotificationProcessing.CurrentThenMostRecent,
+ notificationText);
}
if (FlatStyle == FlatStyle.System)
diff --git a/src/test/unit/System.Windows.Forms/System/Windows/Forms/CheckBoxTests.cs b/src/test/unit/System.Windows.Forms/System/Windows/Forms/CheckBoxTests.cs
index 506c893a1d7..105fe61c1d9 100644
--- a/src/test/unit/System.Windows.Forms/System/Windows/Forms/CheckBoxTests.cs
+++ b/src/test/unit/System.Windows.Forms/System/Windows/Forms/CheckBoxTests.cs
@@ -542,8 +542,10 @@ public void CheckBox_RaiseAutomationEvent_Invoke_Success()
checkBox.Checked = true;
- Assert.Equal(1, accessibleObject.RaiseAutomationEventCallsCount);
- Assert.Equal(1, accessibleObject.RaiseAutomationPropertyChangedEventCallsCount);
+ Assert.Equal(0, accessibleObject.RaiseAutomationEventCallsCount);
+ Assert.Equal(0, accessibleObject.RaiseAutomationPropertyChangedEventCallsCount);
+ Assert.Equal(1, accessibleObject.RaiseAutomationNotificationCallsCount);
+ Assert.Equal(SR.CheckBoxCheckedNotificationText, accessibleObject.LastNotificationText);
Assert.False(checkBox.IsHandleCreated);
}
@@ -736,6 +738,10 @@ public SubCheckBoxAccessibleObject(CheckBox owner) : base(owner)
public int RaiseAutomationPropertyChangedEventCallsCount { get; private set; }
+ public int RaiseAutomationNotificationCallsCount { get; private set; }
+
+ public string LastNotificationText { get; private set; }
+
internal override bool RaiseAutomationEvent(UIA_EVENT_ID eventId)
{
RaiseAutomationEventCallsCount++;
@@ -747,6 +753,16 @@ internal override bool RaiseAutomationPropertyChangedEvent(UIA_PROPERTY_ID prope
RaiseAutomationPropertyChangedEventCallsCount++;
return base.RaiseAutomationPropertyChangedEvent(propertyId, oldValue, newValue);
}
+
+ internal override bool InternalRaiseAutomationNotification(
+ Automation.AutomationNotificationKind notificationKind,
+ Automation.AutomationNotificationProcessing notificationProcessing,
+ string notificationText)
+ {
+ RaiseAutomationNotificationCallsCount++;
+ LastNotificationText = notificationText;
+ return base.InternalRaiseAutomationNotification(notificationKind, notificationProcessing, notificationText);
+ }
}
[WinFormsFact]
@@ -874,10 +890,10 @@ public void CheckBox_ProcessMnemonic_ValidCases(bool useMnemonic, char charCode,
}
[WinFormsTheory]
- [InlineData(Appearance.Button, FlatStyle.Standard, "Test", 12, 8, 100, 20)]
- [InlineData(Appearance.Normal, FlatStyle.System, "Test", 12, 8, 100, 20)]
- [InlineData(Appearance.Normal, FlatStyle.Flat, "Test", 12, 8, 100, 20)]
- [InlineData(Appearance.Normal, FlatStyle.Standard, "Test", 12, 8, 100, 20)]
+ [InlineData(Appearance.Button, FlatStyle.Standard, "Test", 12, 8, 100, 20)]
+ [InlineData(Appearance.Normal, FlatStyle.System, "Test", 12, 8, 100, 20)]
+ [InlineData(Appearance.Normal, FlatStyle.Flat, "Test", 12, 8, 100, 20)]
+ [InlineData(Appearance.Normal, FlatStyle.Standard, "Test", 12, 8, 100, 20)]
public void CheckBox_GetPreferredSizeCore_VariousStyles_ReturnsExpected(
Appearance appearance, FlatStyle flatStyle, string text, int fontSize, int padding, int width, int height)
{