I'm trying to create an overload of my append text so I can customize text on every line but new Font() just "overwrites" (don't know the term, sorry) the lines.
public void AppendThis(string text)
{
Preview.AppendText(text);
Preview.AppendText("\n");
Preview.ScrollToCaret();
}
public void AppendThis(string text, string font, float size)
{
Preview.Font = new Font(font, size);
Preview.AppendText(text);
Preview.AppendText("\n");
Preview.ScrollToCaret();
}
public void AppendThis(string text, string font, float size, FontStyle style)
{
Preview.Font = new Font(font, size, style);
Preview.AppendText(text);
Preview.AppendText("\n");
Preview.ScrollToCaret();
}
I'm trying to display my text like this.
public void DisplayPreview(string path)
{
string jsonfile = File.ReadAllText(path);
Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(jsonfile);
AppendThis(myDeserializedClass.basics.name, "Times New Roman", 20, FontStyle.Bold);
AppendThis(myDeserializedClass.basics.email, "Arial", 20);
AppendThis(myDeserializedClass.basics.location.address);
AppendThis(myDeserializedClass.basics.location.postalCode);
}
Use SelectionFont
property instead of Font
.
public void AppendThis(string text)
{
Preview.AppendText(text);
Preview.AppendText("\n");
Preview.ScrollToCaret();
}
public void AppendThis(string text, string font, float size)
{
Preview.SelectionFont = new Font(font, size);
Preview.AppendText(text);
Preview.AppendText("\n");
Preview.ScrollToCaret();
}
public void AppendThis(string text, string font, float size, FontStyle style)
{
Preview.SelectionFont = new Font(font, size, style);
Preview.AppendText(text);
Preview.AppendText("\n");
Preview.ScrollToCaret();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.