|
-
Sep 23rd, 2022, 05:27 AM
#1
Thread Starter
Addicted Member
[RESOLVED] VB.net change system locale
Hello,
can someone help me out how can it be made to change windows system locale option using vb.net application.
Example:
1 combobox - inside 3 languages ( English, Japan, Romania )
1 button - activate the executable with selected language
i have read some topics from google, but i cannot find some good way, that's why i wanted to ask if someone that knows better this how to be made correctly would be grateful.
i had found one similar solution like:
Code:
Imports System.Globalization
''' <summary>
''' Requires
''' 1 ComboBox: cboCultures
''' 2 TextBoxes: TextBox1, TextBox2
''' 1 DateTimePicker: DateTimePicker1
''' </summary>
Public Class Form1
' Used to set cboCultures selected item and for restoring the current culture
Private OriginalCultureName As String = ""
Private OriginalCultureIndex As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
OriginalCultureName = Application.CurrentCulture.Name
DateTimePicker1.Format = DateTimePickerFormat.Custom
cboCultures.DisplayMember = "DisplayName"
cboCultures.ValueMember = "Code"
cboCultures.DropDownStyle = ComboBoxStyle.DropDownList
Dim CultureList =
(
From cultureitem In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
Order By cultureitem.EnglishName
Select New With
{
.DisplayName = cultureitem.EnglishName,
.Code = cultureitem.Name
}
).ToList
cboCultures.DataSource = CultureList
' get current culture so we can select it in cboCultures
Dim item =
(
From T In CultureList _
.Select(
Function(cultureitem, indexer)
Return New With {.Index = indexer, .Name = cultureitem.Code}
End Function)
Where T.Name = OriginalCultureName
).First
OriginalCultureIndex = item.Index
cboCultures.SelectedIndex = OriginalCultureIndex
Demo()
End Sub
Private Sub cmdChange_Click(sender As Object, e As EventArgs) Handles cmdChange.Click
Application.CurrentCulture = New CultureInfo(cboCultures.SelectedValue.ToString)
Demo()
End Sub
''' <summary>
''' Show results for date and double
''' </summary>
Private Sub Demo()
DateTimePicker1.CustomFormat = DateTimeFormatInfo.CurrentInfo.FullDateTimePattern
TextBox1.Text = DateTimePicker1.Value.ToString
Dim value As Double = 123.456789
TextBox1.Text = value.ToString("c2")
TextBox2.Text = String.Format("{0:c2}", value)
End Sub
Private Sub cmdRestore_Click(sender As Object, e As EventArgs) Handles cmdRestore.Click
Application.CurrentCulture = New CultureInfo(OriginalCultureName)
cboCultures.SelectedIndex = OriginalCultureIndex
cmdChange.PerformClick()
Demo()
End Sub
End Class
Last edited by luckydead; Sep 23rd, 2022 at 05:45 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|