相关疑难解决方法(0)

在TextBox中制作特定的文本Boldefaced

嗨我目前有一个texbox,当用户按下不同的按钮时会向用户输出信息.我想知道是否有办法让我的一些文字加粗,其余的不是.

我尝试过以下方法:

textBox1.FontWeight = FontWeights.UltraBold;
textBox1.Text. = ("Your Name: " );
TextBox1.FontWeight = FontWeights.Regular;
textBox1.Text += (nameVar);
Run Code Online (Sandbox Code Playgroud)

唯一的问题是,使用这种方式会使一切变得大胆或什么都没有.有没有办法做到这一点?我在C#中使用WPF项目

任何意见或建议表示赞赏.谢谢!

编辑:所以现在我想尝试你所有建议的RichText框,但我似乎无法得到任何东西出现在其中:

// Create a simple FlowDocument to serve as the content input for the construtor.
FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("Simple FlowDocument")));
// After this constructor is called, the new RichTextBox rtb will contain flowDoc.
RichTextBox rtb = new RichTextBox(flowDoc);
Run Code Online (Sandbox Code Playgroud)

rtb是我在我的wpf中创建的我的richtextbox的名称

谢谢

c# wpf textbox bold

16
推荐指数
3
解决办法
6万
查看次数

标签 统计

bold ×1

c# ×1

textbox ×1

wpf ×1