title | description | ms.date | ms.topic | f1_keywords | helpviewer_keywords | author | ms.author | manager | ms.subservice | dev_langs | monikerRange | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CA1300: Specify MessageBoxOptions |
A method calls an overload of the System.Windows.Forms.MessageBox.Show method that does not take a MessageBoxOptions argument. |
11/04/2016 |
reference |
|
|
mikejo5000 |
mikejo |
mijacobs |
code-analysis |
|
vs-2019 |
Item | Value |
---|---|
RuleId | CA1300 |
Category | Microsoft.Globalization |
Breaking change | Non-breaking |
A method calls an overload of the xref:System.Windows.Forms.MessageBox.Show%2A?displayProperty=fullName method that does not take a xref:System.Windows.Forms.MessageBoxOptions?displayProperty=fullName argument.
To display a message box correctly for cultures that use a right-to-left reading order, pass the MessageBoxOptions.RightAlign and MessageBoxOptions.RtlReading fields to the xref:System.Windows.Forms.MessageBox.Show%2A method. Examine the xref:System.Windows.Forms.Control.RightToLeft%2A?displayProperty=fullName property of the containing control to determine whether to use a right-to-left reading order.
To fix a violation of this rule, call an overload of the xref:System.Windows.Forms.MessageBox.Show%2A method that takes a xref:System.Windows.Forms.MessageBoxOptions argument.
It is safe to suppress a warning from this rule when the code library will not be localized for a culture that uses a right-to-left reading order.
The following example shows a method that displays a message box that has options that are appropriate for the reading order of the culture. A resource file, which is not shown, is required to build the example. Follow the comments in the example to build the example without a resource file and to test the right-to-left feature.
:::code language="csharp" source="../snippets/csharp/VS_Snippets_CodeAnalysis/FxCop.Globalization.SpecifyMBOptions/cs/FxCop.Globalization.SpecifyMBOptions.cs" id="Snippet1":::
:::code language="vb" source="../snippets/visualbasic/VS_Snippets_CodeAnalysis/FxCop.Globalization.SpecifyMBOptions/vb/FxCop.Globalization.SpecifyMBOptions.vb" id="Snippet1":::
- xref:System.Resources.ResourceManager?displayProperty=fullName
- Resources in desktop apps (.NET Framework)