Avatar of Murray Brown
Murray Brown
Flag for United Kingdom of Great Britain and Northern Ireland asked on

VB.net DataGridView more additional columns than expected being added in

Hi. I am using the following code to populate a bound DataGridView and then add in an additional CheckBox column but for some reason 3 extra CheckBox columns are being added. Thanks      

          Dim connection As New OleDbConnection(ConnectionString)
                Dim dataadapter As New OleDbDataAdapter(sSQL, connection)
                Dim ds As New DataSet()
                dataadapter.Fill(ds, "Outstanding_table")
                DataGridView_Unpaid_Invoices.DataSource = ds
                DataGridView_Unpaid_Invoices.DataMember = "Outstanding_table"

            Me.DataGridView_Unpaid_Invoices.Columns.Insert(0, New DataGridViewCheckBoxColumn)
Visual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon

the code you are using has no faults, anyway use this property to avoid adding more columns
 DataGridView1.AutoGenerateColumns = false
Murray Brown

Hi. Thanks for the code but nothing seems to change with your code

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Murray Brown

Right on! I  was calling the code from more than one event. Clearing the extra column at the beginning did the trick! Thanks for confirming that it works
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

ur welcome dude.. glad it worked