Library tutorials & articles
Multilingual Support in C#
- Introduction
- Windows 2000
- A Message Box Demo
A Message Box Demo
Create a Windows Application. Place a button in the centre of form. Set the name and text properties of the button to btnMessage and "Show Message" respectively. For displaying Message Box, add following code to the Click event of btnMessage.
protected void btnMessage_Click (object sender, System.EventArgs e)
{
MessageBox.Show("English Text Example","English Title");
}
On Pressing F5, Form will be displayed and on clicking Show Message. Message Box will be displayed.
Now for displaying Arabic text, type message and title using Arabic characters. The Message is " Urdu Text Example" and "Urdu Title" in Urdu Language.
The message box displayed by clicking Show Message Button will be
The Message box displays Urdu Text(in Arabic Script). but it has some problems. Arabic Script is written from Right to Left(The rightmost character is first character of string, and leftmost is the last character of string). So the text must be right aligned. In the above example both Title and Message are left aligned. Also the Title must be at right and the Close Button should be at left in a RightToLeft Scheme. This can be done by using style attributes as third parameter of MessageBox.Show method. Style Attributes are used to change the visual style and options of Message Box. For Example, for displaying a Cancel button with OK button, MessageBox.OKCancel is used as
MessageBox.Show("Message","Title",MessageBox.OKCancel);
For RightToLeft MessageBox, RTLReading field is used. And for right aligning the
text, RightAlign field is used. So in our new example these two are ORed and passed
to Show method of MessageBox(you can OR multipe fields to give their style to
MessageBox).
In above examples, we use Windows 2000 support to insert Arabic (Urdu) characters to the code. But if the development environment does not have support for writing multilingual characters, then this work can be done by code. The character datatype of C# stores characters as Unicode character. So we can declare variables of character and string type and assign characters and words of different languages to these variables.
Related articles
Related discussion
-
C# video Editing/rendering
by pkuchaliya (0 replies)
-
How to Fill DataSet with more records (around 1 lakh) in a faster way
by Jayaram P (0 replies)
-
Can't print on the network with MSADESS ??
by anatha1 (2 replies)
-
Very Urgent regarding deleting the images from a folder
by Nanosteps (6 replies)
-
DataGridViewComboBoxColumn not showing values
by sachinkalse (0 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
I think the reason is that the string stored in the database is not in unicode, whereas chinese or Urdu or any such language needs unicode or some Font for rendering. If it shows ??? it means that the current viewer or the database does not support unicode.
Hope that solved your problem.
I can show up chinese by asp.net, but after I insert the Chinese into English SQL server using c#, it shows up ??? in the database, any idea?
This thread is for discussions of Multilingual Support in C#.