ApplicationBase.ChangeUICulture(String) メソッド
定義
現在のスレッドがカルチャ固有のリソースを取得するために使用しているカルチャを変更します。Changes the culture that the current thread uses for retrieving culture-specific resources.
public:
void ChangeUICulture(System::String ^ cultureName);
public void ChangeUICulture (string cultureName);
member this.ChangeUICulture : string -> unit
Public Sub ChangeUICulture (cultureName As String)
パラメーター
- cultureName
- String
String
。String
. カルチャの名前を表す文字列。Name of the culture as a string. 使用可能な名前の一覧については、「CultureInfo」を参照してください。For a list of possible names, see CultureInfo.
例外
cultureName
が Nothing
です。cultureName
is Nothing
.
cultureName
が有効なカルチャ名ではありません。cultureName
is not a valid culture name.
例
この例ではMy.Application.ChangeUICulture
、メソッドを使用して、 My.Resources
オブジェクトがリソースを取得するために使用するカルチャを設定します。This example uses the My.Application.ChangeUICulture
method to set the culture that the My.Resources
object uses for retrieving resources.
Sub ShowLocalizedMessage()
Dim culture As String = My.Application.UICulture.Name
My.Application.ChangeUICulture("fr-FR")
MsgBox(My.Resources.Message)
My.Application.ChangeUICulture(culture)
End Sub
この例を使用するには、アプリケーションのリソースファイルにMessage
という文字列が含まれている必要があります。また、アプリケーションには、 Resources.fr-FR.resx
そのリソースファイルのフランス語カルチャバージョンが含まれている必要があります。For this example to work, your application must have a string named Message
in the application's resource file, and the application should have the French-culture version of that resource file, Resources.fr-FR.resx
. 詳細については、「方法 :リソースを追加または削除します。For more information, see How to: Add or Remove Resources.
アプリケーションに、そのリソースファイルのフランス語カルチャバージョンがない場合、オブジェクトはMy.Resources
既定のカルチャリソースファイルからリソースを取得します。If the application does not have the French-culture version of that resource file, the My.Resources
object retrieves the resource from the default-culture resource file.
注釈
メソッドMy.Application.ChangeUICulture
は、現在のスレッドのCurrentUICultureプロパティを変更します。The My.Application.ChangeUICulture
method changes the current thread's CurrentUICulture property. プロパティCurrentUICultureは、リソースマネージャー My.Resources
とオブジェクトによって使用されるカルチャを決定します。この情報は、実行時にカルチャ固有のリソースを検索するために使用されます。The CurrentUICulture property determines the culture used by the Resource Manager and the My.Resources
object; it uses this information to look up culture-specific resources at run time.
現在の UI カルチャを取得するには、 UICultureプロパティCurrentUICultureまたはプロパティを使用します。To retrieve the current UI culture, you can use the UICulture property or the CurrentUICulture property.
My.Application.ChangeCulture
メソッドを使用して、現在のスレッドが文字列の操作と文字列の書式設定に使用するカルチャを変更します。Use the My.Application.ChangeCulture
method to change the culture that the current thread uses for string manipulation and string formatting.
プロジェクトの種類別の可用性Availability by Project Type
プロジェクトの種類Project type | 使用可能Available |
---|---|
Windows フォーム アプリケーションWindows Forms Application | はいYes |
クラス ライブラリClass Library | はいYes |
コンソール アプリケーションConsole Application | はいYes |
Windows フォーム コントロール ライブラリWindows Forms Control Library | はいYes |
Web コントロールライブラリWeb Control Library | いいえNo |
Windows サービスWindows Service | はいYes |
Web サイトWeb Site | いいえNo |