【问题标题】:C# rich text box stylingC# 富文本框样式
【发布时间】:2011-07-27 07:11:18
【问题描述】:

我有一些来自数据库的字符串(段落)。我需要为每个字符串提供单独的格式,如着色、粗体和斜体等。问题是我只能使用单个富文本框。

我的问题的解决方案是什么?

谢谢

【问题讨论】:

  • 当然可以。你试过什么?

标签: .net winforms c#-4.0 richtextbox


【解决方案1】:

对于要对其应用样式的每个字符串,选择字符串,然后应用所需的样式。喜欢:

richTextBox1.Text = "Hi this is a string";
richTextBox1.Select(0, 2);//selects Hi
richTextBox1.SelectionColor = Color.Red;//make its color red
richTextBox1.SelectionFont = new Font("Arial", 15, FontStyle.Bold); apply arial font to it and make it bold

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    • 2012-04-08
    • 1970-01-01
    • 1970-01-01
    • 2011-05-03
    相关资源
    最近更新 更多