难题 - 如何使TextBox始终用英文写 [英] Hard Question - How to make a TextBox always write in English

查看:46
本文介绍了难题 - 如何使TextBox始终用英文写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




对于上周,我正在寻找一种方法让TextBox总是写在

英语(无论什么操作系统默认语言是)。

i在这里问过几次,但我得到的答案对我没有帮助。我搜索了

google并找到了改变CultureInfo的方法,但仍然没有工作

一个TextBox。我确定有办法做到这一点,但我不知道是什么方式。


我很绝望,如果有人知道的话答案,我将非常感谢知道

它也是(例子会很棒....)


谢谢,

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,

推荐答案

Gidi写道:


上周,我正在寻找一种方法使一个TextBox总是用英文写的(无论操作系统的默认语言是什么)。
我在这里问过几次,但我得到的答案对我没有帮助。我在谷歌搜索
并找到了改变CultureInfo的方法,但仍然没有在TextBox上工作。我确定有办法做到这一点,但我不知道那是什么方式。

我很绝望,如果有人知道的话答案,我将非常感谢
也知道它(例子会很棒......)

谢谢,
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,




你的意思是总是用英文写&?我不认为

你的意思是如果用户键入法语(或任何其他语言),请将

翻译成英语 :-)


Hans Kesting



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





我的意思是,无论操作系统默认语言是什么,在文本

框中,它总是会在键盘上输入英文字母。例如,如果我有一个法国键盘我想要打印A(英文)我将按s(在

法语中) - 这意味着如果A(英语) )和s(法语)是键盘上的相同键,键盘总是键入英文字母。我不是故意

翻译。


" Hans Kesting"写道:
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写道:


上周,我正在寻找一种方法来制作一个TextBox总是用英文写的(无论操作系统的默认语言是什么)。
我在这里问过几次,但我得到的答案对我没有帮助。我在谷歌搜索
并找到了改变CultureInfo的方法,但仍然没有在TextBox上工作。我确定有办法做到这一点,但我不知道那是什么方式。

我很绝望,如果有人知道的话答案,我将非常感谢
也知道它(例子会很棒......)

谢谢,
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,



做什么你的意思是总是写英文?我不认为
你的意思是如果用户输入法语(或任何其他语言),翻译
到英语 :-)

Hans Kesting



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



Hello Gidi


你可以做到这一点的一种方法是捕获由击键产生的windows消息




即按键的Lparam是相同的,无论是什么语言设置。


cut''n''将以下内容分别粘贴到表单和类中


表单...


使用System;

使用System.Drawing;

使用System.Collections;

使用System.ComponentModel ;

使用System.Windows.Forms;

使用System.Data;


名称空间TestKB

{

///< summary>

/// Form1的摘要说明。

///< / summary>

公共类Form1:System.Windows.Forms.Form

{

private System.Windows.Forms.TextBox textBox1;

private testMessageFilter fltHelp;

///< su mmary>

///所需的设计变量。

///< / summary>

private System.ComponentModel.Container components = null ;


public Form1()

{

//

// Windows窗体需要设计师支持

//

InitializeComponent();


//创建一个新的messagefilter

fltHelp = new testMessageFilter();

//将过滤器添加到应用程序

Application.AddMessageFilter(fltHelp);


//

// TODO:在InitializeComponent调用后添加任何构造函数代码

//

}


///< summary>

///清理正在使用的所有资源。

///< / summary>

protected override void Dispose(bool disposing)

{

if(disposing)

{

if(components) != null)

{

components.Dispose();

}

}

base.Dispose(处理);

}


#region Windows窗体设计器生成的代码

///< summary>

/// Designer支持所需的方法 - 不要使用代码编辑器修改

///此方法的内容。

///< / 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"; < br $>

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing .Size(5,13);

this.ClientSize = new System.Drawing.Size(360,334);

this.Controls.Add(this.textB ox1);

this.Name =" Form1";

this.Text =" Form1";


this .ResumeLayout(false);


}

#endregion


///< summary>

///应用程序的主要入口点。

///< / summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

}

}


班级....


使用系统;

使用System.Windows.Forms;


名称空间TestKB

{

/// < summary>

/// 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());

}


返回false;


}


public System.Windows.Forms.Form Parent

{

get

{

返回m_Parent;

}

设置

{

m_Parent = value;

}

}


}

}


弹出的消息框表示按下的键而不是

cahracter ...你可以将这些映射到英文键盘字符..


亲切的问候


Ronnie


Gidi ;写道:
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:


上周,我正在寻找一种让TextBox始终用英文写的方法(无论操作系统默认语言是什么)。
我在这里问过几次,但我得到的答案对我没有帮助。我在谷歌搜索并找到了改变CultureInfo的方法,但仍然没有工作
一个TextBox。我确定有办法做到这一点,但我不知道是什么方式。

我很绝望,如果有人知道答案,我非常感谢知道
它(例子会很棒......)

谢谢,
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,



这篇关于难题 - 如何使TextBox始终用英文写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆