[英]Making richtextbox bold in C# .Net
I'm trying to make bold text in richTextBox. 我正在尝试在richTextBox中制作粗体文本。 Text I want to make bold is in a second row "Cpu usage" in code. 我要加粗的文本在代码的第二行“ Cpu用法”中。
Can you edit this code to make it bold? 您可以编辑此代码使其变为粗体吗?
double cpuUsage = Math.Round(perfCpuCount.NextValue(), 2); MonitorLog.AppendText(string.Format("Cpu usage: {0}%\\r\\n\\n", cpuUsage));
Change the SelectionFont
to include the bold style, and write the text that should be bold, then switch it back to regular: 将SelectionFont
更改为包括粗体样式,并写上应为粗体的文本,然后将其切换回常规:
MonitorLog.SelectionFont = new Font(MonitorLog.Font, FontStyle.Bold);
MonitorLog.AppendText("CPU Usage:");
MonitorLog.SelectionFont = new Font(MonitorLog.Font, FontStyle.Regular);
MonitorLog.AppendText(string.Format(" {0}%\r\n\n", cpuUsage));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.