controls in richtextbox
-
Hi, I have got a serious problem. I have connect a table with the windows form. The table looks like Id name age place country 1 sss 11 ttt qqq 2 ww 12 eee qqq Now I'm able to display all of them in a richtextbox in the following format whose country = qqq 1. Id ="1" Name = "sss" age =11 place = "ttt" country = "qqq" 2. Id ="2" Name = "ww" age =12 place = "eee" country = "qqq" now i add a linklabel control to the textbox. the text of the linklabel wiill be the result of Name column when on click it is linked to a webpage. here my problem is it is not scrolling along with text. this is how my code looks : public void button3_Click(object sender, EventArgs e) { OdbcCommand bcC2 = new OdbcCommand(); bcC2.CommandText = "select * from C_RefCitation where c_id like ('" + textBox5.Text + "')"; bcC2.Connection = OdbcCon; DataSet q3 = new DataSet(); OdbcDataAdapter db1A2 = new OdbcDataAdapter(bcC2); db1A2.Fill(q3); dataGridView1.DataSource = q3.Tables[0]; richTextBox2.Visible = true; richTextBox2.Clear(); for (int x = 0; x < dataGridView1.Rows.Count - 1; x++) { richTextBox2.AppendText((x + 1).ToString() + ". "); for (int y = 0; y < dataGridView1.Columns.Count; y++) { richTextBox2.AppendText("\n"); richTextBox2.AppendText(dataGridView1.Columns[y].HeaderText); richTextBox2.AppendText(" : "); if (dataGridView1.Columns[y].HeaderText.ToString() == "c_CitationDOI") { this.richTextBox2.SelectionStart = this.richTextBox2.TextLength; int index = richTextBox2.Text.Length; Point position = richTextBox2.GetPositionFromCharIndex(index); LinkLabel label = new System.Windows.Forms.LinkLabel(); RichTextBox sri = new System.Windows.Forms.RichTextBox(); label.Text = dataGridView1.Rows[x].Cells[y].Value.ToString(); label.AutoSize = true; label.Location = new Point(0,position.Y); label.LinkBehavior = LinkBehavior.NeverUnderline; richTextBox2.Controls.Add(label); richTextBox2.AppendText(label.Text); label.Links.Add(1, 7, dataGridView1.Rows[x].Cells[y].Value.ToString()); label.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.label_LinkClicked); } else { richTextBox2.AppendText(dataGridView1.Rows[x].Cells[y].Value.ToString()); } if (y != dataGridView1.Columns.Count - 1) { richTextBox2.AppendText(", "); } } richTextBox2.AppendText("\n\n\n "); } } please help me in modifying this code so that the controls scroll along with text box. Thank you very much