Skip to content

Latest commit

 

History

History
62 lines (44 loc) · 2.62 KB

ca1300.md

File metadata and controls

62 lines (44 loc) · 2.62 KB
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
SpecifyMessageBoxOptions
CA1300
SpecifyMessageBoxOptions
CA1300
mikejo5000
mikejo
mijacobs
code-analysis
CSharp
VB
vs-2019

CA1300: Specify MessageBoxOptions

Item Value
RuleId CA1300
Category Microsoft.Globalization
Breaking change Non-breaking

Cause

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.

Rule description

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.

How to fix violations

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.

When to suppress warnings

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.

Example

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":::

See also