Reloading MDI Container ?

  • Thread starter Thread starter Corobori
  • Start date Start date
C

Corobori

Hi,

Say a form, a MDI Container, called frmMain; another form frmLanguage
allowing me to change the User Interface Language. Changing the
language works fine when I quit the application and comes back. I would
like to make that more user friendly.

The code in frmLanguage where I am changing the Language.


Select Case Me.chkLanguage.SelectedIndex
Case 0
GlobalValue.SetLanguage = "fr"
Case 1
GlobalValue.SetLanguage = "de"
Case 2
GlobalValue.SetLanguage = "en"
End Select
'SaveSetting("CCBase", "Language", "User",
GlobalValue.SetLanguage)


Dim regVersion As RegistryKey
regVersion =
Registry.CurrentUser.OpenSubKey("Software\\Corobori\\EsabCC", True)
If regVersion Is Nothing Then
' Key doesn't exist; create it.
regVersion =
Registry.CurrentUser.CreateSubKey("Software\\Corobori\\EsabCC")
End If
If (Not regVersion Is Nothing) Then
regVersion.SetValue("Language",
GlobalValue.SetLanguage)
regVersion.Close()
End If


Dim frm As Object
frm = Me.Owner
If frm.name = "frmMain" Then
frm.Recharger() ' <------------
End If


The code in frmMain to reload the MDI Container. It doesn't work, after
running this the application isn't working anymore



Function Recharger()
Const sFName As String = "Recharger"
Try
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(GlobalValue.SetLanguage)
InitializeComponent()
Catch ex As Exception
MessageBox.Show(sFName + ": " + ex.Message, Me.Text,
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Function


Any clue how I should to this ?

Jean-Luc
www.corobori.com
 
Corobori,

I strongly advice you to use the language from the globalization (system
settings). A sample quick and dirty

\\\
Dim Language As InputLanguage = InputLanguage.DefaultInputLanguage
Dim currentlanguage as string =
Language.CurrentInputLanguage.Culture.Name.Substring(0, 2))
///

I don't read from registry as you do. However I see that you use in the
strings the C type notation with double slash. I use in VBNet single
slashes. Therefore try that first because I don't know if the method I use
is using a bug.

I hope this helps,

Cor
 
Back
Top