DataGridView.Rows.Add... problem!

I am facing a problem with adding new row to an existing unbounded DataGridView which contains two columns; the first one is DataGridViewLinkColumn type and the second one is DataGridViewTextBoxColumn type. But I always having an empty cell inside the DataGridViewLinkCell, I am using the following code:

DataGridViewLinkCell aLinkCell = new DataGridViewLinkCell();
aLinkCell.Value = "Something";
MyDataGridView.Rows.Add(new object[] { aLinkCell, "Something" });

Thanks in advance.



Answer this question

DataGridView.Rows.Add... problem!

  • ReiXou

    You just need to set the text



    private void Form1_Load(object sender, EventArgs e)
    {
    DataGridViewLinkColumn lc = new DataGridViewLinkColumn();
    DataGridViewTextBoxColumn tc = new DataGridViewTextBoxColumn();
    dataGridView1.Columns.Add(lc);
    dataGridView1.Columns.Add(tc);
    dataGridView1.Rows.Add(new Object[] { "Hello", "World" });
    }




  • wuboyan

    Thanks, it works now...

    Actually I was doing like this but without success, now I created another project and used your code then it works fine but I am not sure why it did not work for me with the old project. I reset the DataGridView parameters to the defaults then it went OK.

    Thanks


  • DataGridView.Rows.Add... problem!