#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    After changing value in combobox in form,datagridview does not get filled.


    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.
    Code:
    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.Insert(10,cmbCaste) dgvUserDetails.Columns("Caste").DisplayIndex = 10 
    rs.Close()
    It gives me error at line "dgvUserDetails.Columns.Insert(10,cmbCaste) " second time when I change value in comboxbox of FORM.Please help me its urgent.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0
    Solved:::Mentioned displayIndex property for each column in datagridview...
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0
    I am so glad this internet thing works and your article really helped me. Might take you up on that home advice you.

IMN logo majestic logo threadwatch logo seochat tools logo