Click here to Skip to main content
16,020,432 members
Articles / Programming Languages / C#
Tip/Trick

Localization for Common Dialogs in Winform

Rate me:
Please Sign up or sign in to vote.
4.79/5 (16 votes)
3 Apr 2017CPOL 11.4K   9   4
Show different languages of Windows common dialogs, like file open dialog, color palette and font picker

Introduction

This is a tip to show different languages to common dialogs of Windows.

Background

Why did I post this? It is because I failed to get results even after Googling it for three hours, most of the responses were "No, you cannot do it." But, there must be a way.

Using the Code

First, the problem, try the following code anywhere inside a Winform app:

C#
//
// C#
//
OpenFileDialog dlg = new OpenFileDialog();
dlg.ShowDialog();

You will see, the file opens a dialog popup with your OS languages. You could not modify it with properties of OpenFileDialog or CurrentUICulture. See this link.

The solution is easy, and I don't have much experience with Localization projects. I may update this in future if I work more on it.

C#
//
// C#
//
// declare
//
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
static extern System.UInt16 SetThreadUILanguage(System.UInt16 LangId);

//
// Call before popup common dialog
//
SetThreadUILanguage(2052); // Chinese
//

Refer more from MSDN - SetThreadUILanguages.

Points of Interest

Nothing, just keep searching, pop up questions from different points, you may get more.

History

  • 3rd April, 2017: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
China China
I am C++ developer with 14 years experience. I am good at native programming and debugging. I am studying .net now.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Motaz Alnuweiri8-Dec-19 8:46
Motaz Alnuweiri8-Dec-19 8:46 
QuestionNice idea, but incomplete Pin
Bernhard Hiller7-Apr-17 3:29
Bernhard Hiller7-Apr-17 3:29 
PraiseRe: Nice idea, but incomplete Pin
Simon M Li7-Apr-17 17:01
Simon M Li7-Apr-17 17:01 
QuestionThanks Pin
.dan.g.3-Apr-17 21:44
professional.dan.g.3-Apr-17 21:44 
This could be very useful for me.
.dan.g.

AbstractSpoon Software
email: abstractspoon-todolist-support(at)googlegroups(dot)com

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.