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.HeaderText = "jaita"
cmbCaste.Name = "Caste"
dgvUserDetails.Columns("Caste").DisplayIndex = 10
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.
Please help me its urgent.
Why is everything everyone does in India "urgent"??
Sorry, but we're all volunteers here answering question in our own spare time, not when you demand.
If it was that urgent, you should have been reading the documentation on the DGV and its Columns collection class. In there, you would have noticed that instead of Add, you can use an Insert method to put the column anywhere you want into the Columns collection and avoid the error you got.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)