divya

divya

  • NA
  • 186
  • 109.7k

About DataGridview run time column generation

Jul 9 2012 6:25 AM

Hai guys..
  Please see this code...
    DataGridViewColumn col26 = new DataGridViewColumn();
            DataGridViewCell cel26= new DataGridViewTextBoxCell();
            col26.CellTemplate = cel26;
            col26.HeaderText = "TDS";
            col26.Name = "TDS";
            col26.Visible = true;
            col26.Width = 40;
            dgvEmployeeSalary.Columns.Add(col26);
            {
                foreach (DataGridViewRow row in dgvEmployeeSalary.Rows)
                {
                    if (row.Cells["Employee ID"].Value != null)
                    {
                        row.Cells["TDS"].Value = 0;
                    }
                }
            }
 while running ,TDS named column is added to dgvEmployeeSalary.

So here my problem is while iam trying to change the item in combobox TDS row generated for 2 times..it depends on how many times iam changing the item in combobox,the tds count will be incremented.. can any one help me


Thanks & Regards
divya

Answers (2)