我正在尝试将我的标题设置为粗体并保留下划线。例如:
代码不断使所有行加粗。从上图中可以看出,只有标题应该是粗体。如何修复代码以匹配图像?
List<string> titles = new List<string> { "Basic Metabolic Panel", "Complete Blood Count", "Comprehensive Metabolic Panel" };
List<string> bodies = new List<string> { " : Collected: 8/20/2012 5:45:00 PM", " : Collected: 8/20/2012 5:45:00 PM", " : Collected: 8/17/2012 4:18:00 AM" };
for (int i = 0; i < titles.Count; i++)
{
string labName = titles[i];
string collectionDate = bodies[i];
int oldTextEndPoint = rtb.Text.Length;
rtb.Text += labName + collectionDate + Environment.NewLine;
rtb.Select(oldTextEndPoint, labName.Length + collectionDate.Length);
rtb.SelectionFont = new Font(rtb.Font, rtb.SelectionFont.Style | FontStyle.Underline);
rtb.Select(oldTextEndPoint, labName.Length);
rtb.SelectionFont = new Font(rtb.Font, rtb.SelectionFont.Style | FontStyle.Bold);
}