0

I am populating datagridview with 9 columns through dataset. After this I add 4 comboboxes programatically. Now for the first time form loads, everything goes well. But if I change selected value in combobox from FORM,grid does not gets value and it shows error "Column cannot be added because it is unfrozen and placed before a frozen column."..In my datagridview ,columns 1 to 8 are frozen..Below is my code to add combobox in grid at runtime.

sql = "Select Description from Category where Catgry = 1"
        If rs.State = 1 Then rs.Close()
        rs.Open(sql, MainCon, 1, 3)
        Do While Not rs.EOF
            cmbCaste.Items.Add(rs.Fields(0).Value)
            rs.MoveNext()
        Loop
        cmbCaste.HeaderText = "jaita"
        cmbCaste.Name = "Caste"
        dgvUserDetails.Columns.Add(cmbCaste)
        dgvUserDetails.Columns("Caste").DisplayIndex = 10
        rs.Close()

It gives me error at line "dgvUserDetails.Columns.Add(cmbCaste)" second time when I change value in comboxbox of FORM.Please help me its urgent.

Edited by Rachna0309

2
Contributors
1
Reply
6
Views
4 Years
Discussion Span
Last Post by kRod
0

Do you have any hidden columns? if so you might need to unhide them run your sub and then re-hide them.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.