Share via


ApplicationBase.ChangeUICulture(String) 方法

定義

變更目前執行緒用來擷取特定文化特性資源的文化特性。

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. 做為字串的文化特性名稱。 如需可能名稱的清單,請參閱 CultureInfo

例外狀況

cultureNameNothing

cultureName 不是有效的文化特性名稱。

範例

這個範例會 My.Application.ChangeUICulture 使用 方法來設定對象用於擷取資源的文化特性 My.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 如需詳細資訊,請參閱 如何:新增或移除資源

如果應用程式沒有該資源檔的法文文化特性版本, My.Resources 物件會從預設文化特性資源檔擷取資源。

備註

方法 My.Application.ChangeUICulture 會變更目前線程的 CurrentUICulture 屬性。 屬性CurrentUICulture會決定 Resource Manager和 My.Resources 物件所使用的文化特性;它會使用此資訊在運行時間查閱特定文化特性資源。

若要擷取目前的UI文化特性,您可以使用 UICulture 屬性或 CurrentUICulture 屬性。

My.Application.ChangeCulture使用方法來變更目前線程用於字串操作和字串格式的文化特性。

依專案類型的可用性

專案類型 可用
Windows Forms 應用程式
類別庫
主控台應用程式
Windows Form 控制項程式庫
Web 控制項程式庫
Windows 服務
網站

適用於

另請參閱