在表单中更改组合框中的值后,datagridview不会被填充。 [英] After changing value in combobox in form,datagridview does not get filled.

查看:57
本文介绍了在表单中更改组合框中的值后,datagridview不会被填充。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过数据集填充了9列的datagridview。在此之后,我以编程方式添加4个组合框。现在第一次形成负载,一切顺利。但是如果我在FORM中更改了组合框中的选定值,则网格不会获得值并显示错误无法添加列,因为它已解冻并放置在冻结列之前。 ..在我的datagridview中,第1列到第8列被冻结。下面是我在运行时在网格中添加组合框的代码。

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()





第二次我在dgvUserDetails.Columns.Add(cmbCaste)行给出错误更改FORM的comboxbox中的值。请帮助我紧急。



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.

推荐答案

请帮我急。



为什么大家在印度所做的一切都紧急?



对不起,但我们都是志愿者,在我们自己的业余时间回答问题,而不是在你要求的时候。



如果是那么紧急,你应该一直在阅读文件在DGV及其Columns集合类中。在那里,您会注意到,您可以使用Insert方法将列放在Columns集合中,而不是Add,从而避免出现错误。
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.


这篇关于在表单中更改组合框中的值后,datagridview不会被填充。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆