在C#应用中应用文字样式 [英] Applying text style in C# apllication

查看:68
本文介绍了在C#应用中应用文字样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文本上同时使用粗体和斜体样式.我可以一次一个地应用它,但不能同时应用.
谁能帮我这个忙吗?

这是粗体和斜体的代码:
//textarea是richtextbox的名称.

I want to apply both Bold and Italic style on the text. I am able to apply it one by one but not on the same time.
Can anyone help me with this??

Here is the code for the Bold and Italic:
//textarea is a name for richtextbox.

private void boldtoolStripButton_Click(object sender, EventArgs e)
        {
            if (textarea.SelectionFont.Bold == true)
            {
                textarea.Font = new Font(new FontFamily(this.fontNameComboBox.SelectedItem.ToString()), float.Parse(this.fontSizeComboBox.SelectedItem.ToString()), FontStyle.Regular);
            }
            else
            {
                textarea.Font = new Font(new FontFamily(this.fontNameComboBox.SelectedItem.ToString()), float.Parse(this.fontSizeComboBox.SelectedItem.ToString()), FontStyle.Bold);
            }
        }

        private void iItalictoolStripButton_Click(object sender, EventArgs e)
        {
            if (textarea.SelectionFont.Italic == true)
            {
                textarea.Font = new Font(new FontFamily(this.fontNameComboBox.SelectedItem.ToString()), float.Parse(this.fontSizeComboBox.SelectedItem.ToString()), FontStyle.Regular);
            }
            else
            {
                textarea.Font = new Font(new FontFamily(this.fontNameComboBox.SelectedItem.ToString()), float.Parse(this.fontSizeComboBox.SelectedItem.ToString()), FontStyle.Italic);
            }
        }

推荐答案

使用jquery来应用所有样式


Use jquery to apply the styles all


.focus {
    border: 2px solid #AA88FF;
    background-color: #FFEEAA;
}








(''input [type ="text"]'').focus(function(){
(''input[type="text"]'').focus(function() {


(this).addClass("focus");
});

(this).addClass("focus");
});


这篇关于在C#应用中应用文字样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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