Windows 窗体文本框不能粘贴汉字吗

Is it not possible to Paste Chinese Characters on Windows Form Text Box(Windows 窗体文本框不能粘贴汉字吗)
本文介绍了Windows 窗体文本框不能粘贴汉字吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 WinForm 应用程序,并且我有一个文本框,我在其中粘贴来自 Google 翻译的文本.我在几种 Sematic 和 Indo Languages 中取得了积极的结果,但汉字显示为 Boxes.

有什么办法可以克服吗?

解决方案

您应该使用支持 CJK 编码的适当 Unicode 字体.更好的是Arial Unicode MS",但它可能在没有安装 MS Office 的早于 Vista 的操作系统.在这种情况下,您可以使用其他字体,例如NSimSun".

<上一页>string arialUnicodeFontFace = "Arial Unicode MS";字体 unicodeFont = new Font(arialUnicodeFontFace, fontSize);if (unicodeFont.Name != arialUnicodeFontFace)unicodeFont = new Font("NSimSun", fontSize);yourTextBox.Font = unicodeFont;

您还可以查看不同 Windows 版本中所有支持的 CJK 字体的列表:http://en.wikipedia.org/wiki/List_of_CJK_fonts

I am working on a WinForm App and I have a text box where I am pasting texts from Google Translator. I have got positive results with several Sematic and Indo Languages but Chinese characters appear as Boxes.

Is there any way to overcome this?

解决方案

You should use appropriate Unicode font which supports CJK encodings. The better one is "Arial Unicode MS", but it may be absent on OS earlier than Vista without MS Office installed. In this case you may use another font like "NSimSun".

string arialUnicodeFontFace = "Arial Unicode MS";
Font unicodeFont = new Font(arialUnicodeFontFace, fontSize);
if (unicodeFont.Name != arialUnicodeFontFace)
    unicodeFont = new Font("NSimSun", fontSize);

yourTextBox.Font = unicodeFont;

You may also look at the list of all supported CJK fonts in different versions of Windows: http://en.wikipedia.org/wiki/List_of_CJK_fonts

这篇关于Windows 窗体文本框不能粘贴汉字吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)