Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Adding RichTextBox in a DataGridView for being bold or coloring text

$
0
0

Hi

I found this link: vbcity.com/forums/p/164978/704119.aspx#704119 (DataGridView: multiple forecolors in one cell)

I wrote this code:

private void button1_Click(object sender, EventArgs e) { richTextBox1.Select(richTextBox1.Text.IndexOf("aa"), "aa".Length); //richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Bold); richTextBox1.SelectionColor = Color.Red; RTF.RTFBuilder sb = new RTF.RTFBuilder(); dataGridView1.Columns.Add(new DataGridViewRichTextBox.RichTextBoxColumn2()); DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[1]; //sb.AppendLine("Line 1"); //sb.ForeColor(KnownColor.Red).AppendLine("Line 2"); //sb.AppendLine("Line 3"); sb.Append(richTextBox1.Rtf); row.Cells[0].Value = sb.ToString(); }

But I do not have any color text or bold text in readonly datagridview.



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>