Hi,

How to globlize the form.

Ok, before all the Gods here jump on you (someone has already dinged your post's rating, and it wasn't me) ... you need to explain why you would want to make a form global?

There is a rule in C# that is golden and almost always true: If you have to make it global, you probably aren't doing it right.

And take it from someone that came from languages that allowed all the global objects you wanted to create ... as frustrating as it can be to try to figure out how to move data around ... making things global in C# can (and usually will) introduce as many problems as it solves.

That said, you can instance classes before Application.Run() in your Main() ... see program.cs in your solution manager.

Edited 6 Years Ago by Zinderin: n/a

Hi,

I Know that some changes have to perform to do so,

Steps:

set forms Localizable property to true.

set Language property to as per we want to globalize the controls in language.

It will create a separate resource file of that particular language.

I have used these steps but not work for me. It display the default language at run time.I dont know waht is going wrong why i cant get the proper output.Is I have to perform the coding on that....

Hi

How do I globlize the windows form in C#.

I have create three resource file in english and second is in other language and write some code on form as bellow

using System.Globalization;
using System.Threading;


[B]On form load[/B]


   private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("English");
            comboBox1.Items.Add("Spanish");
            comboBox1.Items.Add("French");
            comboBox1.SelectedIndex = 0;
        }

[B]On comboBox[/B]
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem.ToString() == "English")

{
                ChangeLanguage("en");
            }
            else if (comboBox1.SelectedItem.ToString() == "Spanish")
            {
                ChangeLanguage("es-ES");
            }
            else
            {
                ChangeLanguage("fr-FR");
            }
        }
 
        private void ChangeLanguage(string lang)
        {
            foreach (Control c in this.Controls)
            {
                ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
                resources.ApplyResources(c, c.Name, new CultureInfo(lang));
            }
        }

This code run withpou any error but not displaing any output

Can you help me to solve this problem

Edited 6 Years Ago by virusisfound: n/a

Curious...

Was there a reason why you had to create another thread instead of simply adding to the one you created before for the same topic?

Just seems like you decided that, since you didn't get the answer you wanted 5 days ago, you were going to re-post the question again rather than adding your new info to the existing thread where it belonged.

Comments
agreed..duplicate threads = unclean..UNCLEEEAAN! :p

As you are using Form1 for the base type of the ComponentResourceManager,
it is looking for resource starting with Form1..
Check that your resource files are named like this Form1.en.resx, Form1.es.resx, and Form1.fr.resx.

Sorry for posting new thread. I don’t remember that I should make the changes in my first post but next time I will remember that think. Thank you for make me correct all time. Lusiphur and daniweb

Thank nick.carne for reply.I tried to get Form1.fr-FR.recx but that form is not accessable in ComponentResourceManager. How to access that form can you tell me. Please

This article has been dead for over six months. Start a new discussion instead.