使用文本框输入汉字 [英] input chinese character using text box

查看:108
本文介绍了使用文本框输入汉字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有文本框和按钮的c#表单应用程序.我在文本框中键入中文字符,然后按以下按钮使用以下代码将输入分配给字符串

I have a c# form application with a text box and a button. I type Chinese character in the text box and press the button to assign the input to a string using the following code

<br />
String  chineseChar = Textbox1.Text ; 


//TextBox字体属性:Arial Unicode MS或SimSun

但是它将空字符串分配给chineseChar变量.

当我从MS单词中复制中文文本并将其粘贴到文本框中时,它会起作用.

问题出在哪里?

环境:

VS 2008,C#.net框架3.5

Windows XP或更高版本

拼音输入法编辑器3.0版本


// TextBox font property: Arial Unicode MS or SimSun

But it assigns empty string to chineseChar variable.

When I copy a chinese text from a MS word and paste it to the textbox, it works.

Where the problem?

Environment:

VS 2008, C# .net framework 3.5

Windows XP or upper

Ms PinYin IME 3.0

推荐答案

此StackOverflow线程似乎在同一问题上:

http://stackoverflow.com/questions/3287180/将控件放在自定义文本框中 [
This StackOverflow thread seems to be on the same issue:

http://stackoverflow.com/questions/3287180/putting-ime-in-a-custom-text-box-derived-from-control[^]

In his case he''s using a custom control, but you may need to do something similar with a TextBox too.


它可以工作.

在文本框中回显汉字花了一些时间.我在所有字符在文本框中回显之前按下了按钮,这就是为什么它分配了空字符串.

谢谢大家的答复.
It works.

it took some time to echo chinese character in the text box. I pressed button before all characters echo in the text box and that''s why it assigned empty string.

Thanks all for response.


这篇关于使用文本框输入汉字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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