如何一一抓取存储在文本框中的字体? [英] How to catch fonts one by one which are stored in text box?

查看:120
本文介绍了如何一一抓取存储在文本框中的字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我逐一捕获存储在文本框中的字体,C#Windows应用程序窗体吗?

例如:
假设Textbox.text =" M yText"
需要将字体"M"捕获到变量中.

谢谢.

Please help me to catch fonts one by one which are stored in text box,c# windows application form?

Eg:
suppose Textbox.text="MyText"
needs to catch font "M" into a variable.

Thanks.

推荐答案

正如韦斯所说,"M"不是字体.更重要的是,TextBoxes没有单独的字体-TextBox中的文本始终使用相同的字体.

如果您要查找的是文本框中的每个字符,则Text属性是普通的string,因此您可以遍历它们:
As Wes says, "M" is not a font. More to the point, TextBoxes do not have separate fonts - the text in a TextBox is always in the same font.

If what you are after is each character in the textbox, then the Text property is a normal string, so you can either loop through them:
foreach (char c in myTextBox.Text)
   {
   Console.WriteLine(c);
   }


或者,您也可以使用索引直接访问它们:


Or you can access them directly with an index:

for (int i = 0; i < myTextBox.Text.Length; i++)
   {
   Console.WriteLine(myTextBox.Text[i]);
   }


这篇关于如何一一抓取存储在文本框中的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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