473,416 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Hard Question - How to make a TextBox always write in English

Hi,

For the last week, i'm looking for a way to make a TextBox always write in
English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search in
google and found a way with changing the CultureInfo but still didn't work on
a TextBox. i'm sure there's a way to do that, but i don't know what's the way.

I'm desperate, if some one knows the answer, i will be very thankful to know
it also (example will be great....)

Thanks,
Nov 17 '05 #1
14 2905
Gidi wrote:
Hi,

For the last week, i'm looking for a way to make a TextBox always
write in English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search
in google and found a way with changing the CultureInfo but still
didn't work on a TextBox. i'm sure there's a way to do that, but i
don't know what's the way.

I'm desperate, if some one knows the answer, i will be very thankful
to know it also (example will be great....)

Thanks,


What do you mean by "always write in English"? I don't think
you mean "if the user types French (or any other language), translate
to English" :-)

Hans Kesting
Nov 17 '05 #2
Hi,

What i mean is, that no matter what the OS default language is, in the text
box it will always type the English Letter on the keyboard. for example if i
have a french keyboard and i want to print A (in english) i will press s (in
french) - meaning that if the A (english) and s (french) are the same key on
the keyboard it will always type the english letter. i don't mean to
translate.

"Hans Kesting" wrote:
Gidi wrote:
Hi,

For the last week, i'm looking for a way to make a TextBox always
write in English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search
in google and found a way with changing the CultureInfo but still
didn't work on a TextBox. i'm sure there's a way to do that, but i
don't know what's the way.

I'm desperate, if some one knows the answer, i will be very thankful
to know it also (example will be great....)

Thanks,


What do you mean by "always write in English"? I don't think
you mean "if the user types French (or any other language), translate
to English" :-)

Hans Kesting

Nov 17 '05 #3
Hello Gidi

One way you could do this is by trapping the windows message that is
generated by the keystroke.

i.e. the Lparam of the keystroke is the same regardless of language settings.

cut 'n' paste the following into a form and a class respectively

Form...

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestKB
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private testMessageFilter fltHelp;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//create a new messagefilter
fltHelp = new testMessageFilter();
//add the filter to the application
Application.AddMessageFilter(fltHelp);

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(88, 64);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";

//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 334);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";

this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

}
}


Class....

using System;
using System.Windows.Forms ;

namespace TestKB
{
/// <summary>
/// Summary description for MessageFilter.
/// </summary>
public class testMessageFilter:IMessageFilter
{
private System.Windows.Forms.Form m_Parent;

public bool PreFilterMessage(ref Message m)
{

if (m.Msg <30000 & m.Msg != 280)
{
MessageBox.Show(m.LParam.ToString());
}

return false;

}

public System.Windows.Forms.Form Parent
{
get
{
return m_Parent ;
}
set
{
m_Parent = value;
}
}

}
}

the messageboxes that pop represent the key that is pressed not the
cahracter... you can map these to english keyboard characters..

kind regards

Ronnie

"Gidi" wrote:
Hi,

For the last week, i'm looking for a way to make a TextBox always write in
English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search in
google and found a way with changing the CultureInfo but still didn't work on
a TextBox. i'm sure there's a way to do that, but i don't know what's the way.

I'm desperate, if some one knows the answer, i will be very thankful to know
it also (example will be great....)

Thanks,

Nov 17 '05 #4
Ronnie,

First of all Thanks.

i tried that, but what i need is not to know which key was pressed. i want
to draw\print in the text box only the English Letters. i need that TextBox
will show only English Letters.
i.e. if my default langauge is French and i want to enter my name to that
textbox in english, i won't be have to change the langauge (by pressing
Alt+Shift), just by typing Gidi using the english Keys in the keyboard and
the textbox will display Gidi.

"Ronnie Edgar" wrote:
Hello Gidi

One way you could do this is by trapping the windows message that is
generated by the keystroke.

i.e. the Lparam of the keystroke is the same regardless of language settings.

cut 'n' paste the following into a form and a class respectively

Form...

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestKB
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private testMessageFilter fltHelp;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//create a new messagefilter
fltHelp = new testMessageFilter();
//add the filter to the application
Application.AddMessageFilter(fltHelp);

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(88, 64);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";

//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 334);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";

this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

}
}


Class....

using System;
using System.Windows.Forms ;

namespace TestKB
{
/// <summary>
/// Summary description for MessageFilter.
/// </summary>
public class testMessageFilter:IMessageFilter
{
private System.Windows.Forms.Form m_Parent;

public bool PreFilterMessage(ref Message m)
{

if (m.Msg <30000 & m.Msg != 280)
{
MessageBox.Show(m.LParam.ToString());
}

return false;

}

public System.Windows.Forms.Form Parent
{
get
{
return m_Parent ;
}
set
{
m_Parent = value;
}
}

}
}

the messageboxes that pop represent the key that is pressed not the
cahracter... you can map these to english keyboard characters..

kind regards

Ronnie

"Gidi" wrote:
Hi,

For the last week, i'm looking for a way to make a TextBox always write in
English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search in
google and found a way with changing the CultureInfo but still didn't work on
a TextBox. i'm sure there's a way to do that, but i don't know what's the way.

I'm desperate, if some one knows the answer, i will be very thankful to know
it also (example will be great....)

Thanks,

Nov 17 '05 #5
If you're talking about the keyboardlayout:
Look for InputLanguage

Christof

"Gidi" <sh*****@hotmail.com.dontspam> schrieb im Newsbeitrag
news:F3**********************************@microsof t.com...
Hi,

For the last week, i'm looking for a way to make a TextBox always write in
English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search in
google and found a way with changing the CultureInfo but still didn't work
on
a TextBox. i'm sure there's a way to do that, but i don't know what's the
way.

I'm desperate, if some one knows the answer, i will be very thankful to
know
it also (example will be great....)

Thanks,

Nov 17 '05 #6
HI Gidi

I don't think what you are trying to do is possible, as far as I am aware
there is no internal .net way to know that w on an english keyboard = z on a
french keyboard, so you will have to trap the keystrokes and somehow get
their source and then map these to english characters.

using the method outlined below, you get the following results.

when the key is located in the following UK position:

a the lparam for the message is 1966081 if you pressed the q key in france
(press the a key UK you get the same message)

q the lparam is 1048577 this is the french a key,

so you need to trap these messages, and map these to the UK equivalent
characters for these messages. therefore you will have to proxy the textbox
with the filter class

regards

Ronnie

"Gidi" wrote:
Ronnie,

First of all Thanks.

i tried that, but what i need is not to know which key was pressed. i want
to draw\print in the text box only the English Letters. i need that TextBox
will show only English Letters.
i.e. if my default langauge is French and i want to enter my name to that
textbox in english, i won't be have to change the langauge (by pressing
Alt+Shift), just by typing Gidi using the english Keys in the keyboard and
the textbox will display Gidi.

"Ronnie Edgar" wrote:
Hello Gidi

One way you could do this is by trapping the windows message that is
generated by the keystroke.

i.e. the Lparam of the keystroke is the same regardless of language settings.

cut 'n' paste the following into a form and a class respectively

Form...

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TestKB
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private testMessageFilter fltHelp;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//create a new messagefilter
fltHelp = new testMessageFilter();
//add the filter to the application
Application.AddMessageFilter(fltHelp);

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(88, 64);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";

//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 334);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";

this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

}
}


Class....

using System;
using System.Windows.Forms ;

namespace TestKB
{
/// <summary>
/// Summary description for MessageFilter.
/// </summary>
public class testMessageFilter:IMessageFilter
{
private System.Windows.Forms.Form m_Parent;

public bool PreFilterMessage(ref Message m)
{

if (m.Msg <30000 & m.Msg != 280)
{
MessageBox.Show(m.LParam.ToString());
}

return false;

}

public System.Windows.Forms.Form Parent
{
get
{
return m_Parent ;
}
set
{
m_Parent = value;
}
}

}
}

the messageboxes that pop represent the key that is pressed not the
cahracter... you can map these to english keyboard characters..

kind regards

Ronnie

"Gidi" wrote:
Hi,

For the last week, i'm looking for a way to make a TextBox always write in
English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search in
google and found a way with changing the CultureInfo but still didn't work on
a TextBox. i'm sure there's a way to do that, but i don't know what's the way.

I'm desperate, if some one knows the answer, i will be very thankful to know
it also (example will be great....)

Thanks,

Nov 17 '05 #7
Thanks,

If i set the InputLanguage to English (by the way how do i do that?), will
my textBox write only in English (at least until the user will change it)?

"Christof Nordiek" wrote:
If you're talking about the keyboardlayout:
Look for InputLanguage

Christof

"Gidi" <sh*****@hotmail.com.dontspam> schrieb im Newsbeitrag
news:F3**********************************@microsof t.com...
Hi,

For the last week, i'm looking for a way to make a TextBox always write in
English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search in
google and found a way with changing the CultureInfo but still didn't work
on
a TextBox. i'm sure there's a way to do that, but i don't know what's the
way.

I'm desperate, if some one knows the answer, i will be very thankful to
know
it also (example will be great....)

Thanks,


Nov 17 '05 #8
You need to install the language you want to convert to, so if you are in
france and you want to convert to english layout you need to install the
english layout on the machine. Be aware that setting the
inputlanguage.CurrentLanguage or wahtever affects the whole thread, and not
just the textbox.

have a look at the InputLanguage Class and you will see usage.

regards

ronnie

"Gidi" wrote:
Thanks,

If i set the InputLanguage to English (by the way how do i do that?), will
my textBox write only in English (at least until the user will change it)?

"Christof Nordiek" wrote:
If you're talking about the keyboardlayout:
Look for InputLanguage

Christof

"Gidi" <sh*****@hotmail.com.dontspam> schrieb im Newsbeitrag
news:F3**********************************@microsof t.com...
Hi,

For the last week, i'm looking for a way to make a TextBox always write in
English (No matter what the OS default language is).
i asked here few times but the answers i got didn't help me. i search in
google and found a way with changing the CultureInfo but still didn't work
on
a TextBox. i'm sure there's a way to do that, but i don't know what's the
way.

I'm desperate, if some one knows the answer, i will be very thankful to
know
it also (example will be great....)

Thanks,


Nov 17 '05 #9
Thanks, Ronnie.

I have Hebrew and English installed on my machine, and i want to put my
program in machines that the default language is Hebrew (those machine will
have hebrew and english installed too). what i'm thinking to do is to change
the language each time the TextBox Get\Lose Focus, what do you think?

"Ronnie Edgar" wrote:
You need to install the language you want to convert to, so if you are in
france and you want to convert to english layout you need to install the
english layout on the machine. Be aware that setting the
inputlanguage.CurrentLanguage or wahtever affects the whole thread, and not
just the textbox.

have a look at the InputLanguage Class and you will see usage.

regards

ronnie

"Gidi" wrote:
Thanks,

If i set the InputLanguage to English (by the way how do i do that?), will
my textBox write only in English (at least until the user will change it)?

"Christof Nordiek" wrote:
If you're talking about the keyboardlayout:
Look for InputLanguage

Christof

"Gidi" <sh*****@hotmail.com.dontspam> schrieb im Newsbeitrag
news:F3**********************************@microsof t.com...
> Hi,
>
> For the last week, i'm looking for a way to make a TextBox always write in
> English (No matter what the OS default language is).
> i asked here few times but the answers i got didn't help me. i search in
> google and found a way with changing the CultureInfo but still didn't work
> on
> a TextBox. i'm sure there's a way to do that, but i don't know what's the
> way.
>
> I'm desperate, if some one knows the answer, i will be very thankful to
> know
> it also (example will be great....)
>
> Thanks,

Nov 17 '05 #10
Hi Gidi

That should work,

kind regards

Ronnie

Nov 17 '05 #11
Hi Ronnie,

if my Default langauage is Hebrew, how can i set the InputLangauge to be
English. there are only 2 kins of parameters CurrentLangauge and
DefaultLanguage, and when i look at the example in MSDN i get the same result
because when i start my program my default langauge is my current langauge.
so how can i change it?

"Ronnie Edgar" wrote:
Hi Gidi

That should work,

kind regards

Ronnie

Nov 17 '05 #12
Hi Ronnie,

i'm Happy to announce that i found a simple solution to this problem:

i'm checking if my current language is not english and while it's not i'm
sending alt+shift using SendKeys.Send("+%");

is there a better way to know what is the current language then :
if(myCurrentLanguage.Culture.EnglishName!="English (United States)")

the problem here is, if it won't be English United Sates and it will be
English UK it still be good but the alt+shift event will be called.

what do you think about my solution?
Thank you very much for your help
Gidi
"Ronnie Edgar" wrote:
Hi Gidi

That should work,

kind regards

Ronnie

Nov 17 '05 #13
Hi Gidi
if you use InputLanguage.CurrentInputLanguage and set it it sets the
language only for the program... and not! for the computer so you will not
see the language change at machine level only at application level.

regards
ronnie

Nov 17 '05 #14
Hi Gidi,

to get the InputLanguage you wish you can use the InputLanguage.FromCulture
method.

Christof

"Gidi" <sh*****@hotmail.com.dontspam> schrieb im Newsbeitrag
news:C0**********************************@microsof t.com...
Hi Ronnie,

if my Default langauage is Hebrew, how can i set the InputLangauge to be
English. there are only 2 kins of parameters CurrentLangauge and
DefaultLanguage, and when i look at the example in MSDN i get the same
result
because when i start my program my default langauge is my current
langauge.
so how can i change it?

"Ronnie Edgar" wrote:
Hi Gidi

That should work,

kind regards

Ronnie

Nov 17 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
33
by: Xah Lee | last post by:
The Harm of hard-wrapping Lines 20050222 Computing Folks of the industry: please spread the debunking of the truncating line business of the fucking unix-loving fuckheads, as outlines here:...
4
by: Gidi | last post by:
Hi, my user default language is hebrew but in some cases i want that the default language in specific textBox will be english (i mean that when the user will hit the 'T' key he will get a T in...
1
by: Gidi | last post by:
Hi, I have a TextBox, and i want that when ever it gets focused i will call an event who preform like ALT + SHIFT (meaning, change the language of the textbox). What i actually need is, to make...
1
by: Johann Blake | last post by:
I have a form with a single textbox control which is bound to a DataRelation in a typed dataset. The textbox displays the name of the product depending on the language selected from a combobox....
5
by: Steve S | last post by:
Heres what I want to do...User types into a texbox, clicks a button, the button saves that text to a file. The problem is that when I click the submit button, any changes made to the textbox are...
6
by: Henri | last post by:
Very strange problem : if I write: <asp:TextBox runat="server" id="myBox" /> the control's ViewState stays always empty, so it loses its properties if it's not always displayed. But if I...
4
by: Dado | last post by:
I have a next situation with the textbox field: A - B = C 1. How to fill the A fill with the data from my previous recordset ? Can I do it with the expression builder ? 2. I want that every...
1
by: Andrea | last post by:
Hallo, I'll try to explain me in english.... sorry for my results. I'm trying to use a gridview update function. (C#) These are my first experiments in asp.net I'have this TemplateField ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.