Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a requirement to read a file and display in datagridview - It's done.

I have a different functionalities like Add a new column to grid and Merge the columns in grid.
When i add a new column to the grid, the column and it's value is adding. Now, if i go and check the dropdown of "Merging 2 columns" (dropdowns), i can't see the newly added column.

Below is my code for ADD COLUMN:
C#
private void btnAddColumn_Click(object sender, EventArgs e)
{
    frmAddColumn fac = new frmAddColumn();
    fac.ShowDialog();

    DataGridViewTextBoxColumn dgvc = new DataGridViewTextBoxColumn();
    dgvc.Name = fac.txtColumnName.Text;
    dgvc.HeaderText = fac.txtColumnName.Text;

    dataGridView1.Columns.Add(dgvc);

    for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
    {
        dataGridView1.Rows[i].Cells[fac.txtColumnName.Text].Value = fac.txtColumnValue.Text;
    }
    AddColumn(fac.txtColumnName.Text, fac.txtColumnValue.Text);

}
Posted
Updated 2-Feb-16 1:03am
v2
Comments
Sinisa Hajnal 2-Feb-16 6:30am    
You have to call the method that fills the combobox again. This code is irrelevant to the problem described. Post the code that fills your drop down box.
Anisuzzaman Sumon 2-Feb-16 6:50am    
Yes as sinisa said show up the code of populating your dropdownlist
lukeer 2-Feb-16 7:04am    
Please enclose your code with tags like these:
<pre lang="C#">YourCodeHere();</pre>
It makes code a lot more readable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900