用于附加文本
private void AddText(string text)
{
string[] str = text.Split(new string[] { ";" },
StringSplitOptions.RemoveEmptyEntries);
if (str.Length == 2)
{
richTextBox1.DeselectAll();
richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold);
richTextBox1.AppendText(Environment.NewLine + str[0] + ";");
richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Regular);
richTextBox1.AppendText(str[1]);
}
}
用于附加图像
Image image = Image.FromFile("Logo.jpg");
// Put the image on the clipboard
Clipboard.SetImage(image);
//// Paste it into the rich tetx box.
richTextBox1.Paste();
我不知道如何创建像 This image 这样的 RichTextBox?
最佳答案
您可以创建一个 2 行 x 3 列的表格并将元素添加到相应的单元格中。如果您不希望其边框出现,请使用颜色表中的白色 \brdrcf1
标签。
有关 rtf 表的更多信息:
Using Tables in RTF
关于c# - 在 RichTextBox 中附加文本和图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11086041/