更改richtextbox中文本的textstyle或fontstyle [英] change the textstyle or fontstyle of a text in a richtextbox

查看:117
本文介绍了更改richtextbox中文本的textstyle或fontstyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计

我试图在丰富的盒子里改变文字(文字)的fontstyle或textstyle

i在组合框中列出了一些这些字体样式(Arial, Cambria,Tahoma)

我想要做的是当你选择textstyle我希望richtextbox中的文本根据组合框中选择的字体进行更改



i已经尝试过几个代码,但有些代码无效,有些代码给了我错误



这里是我试过的最后一个代码


if(toolStripComboBox2.SelectedItem == @" Tahoma")

richTextBox1.SelectionFont = new FontStyle(richTextBox1.SelectionFont.FontFamily,Tahoma);

hey guys
am trying to change fontstyle or textstyle of text(writing) in a rich box
i got some of these font style listed in a combobox (Arial,Cambria,Tahoma)
what i want to do is when you select a textstyle i want the text in the richtextbox to be change according to the selected font in the combobox

i have already tried a few codes but some would not work and some gave me errors

here is the last code i have tried

if (toolStripComboBox2.SelectedItem == @"Tahoma")
richTextBox1.SelectionFont = new FontStyle(richTextBox1.SelectionFont.FontFamily, Tahoma);

推荐答案

Font font_to_apply = richTextBox1.Font;
            font_to_apply = new Font(new FontFamily(fontNameComboBox.SelectedItem.ToString()), float.Parse(this.fontSizeComboBox.SelectedItem.ToString()));

            richTextBox1.SelectionFont = font_to_apply;


这篇关于更改richtextbox中文本的textstyle或fontstyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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