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()
                connection.Open()
                dataadapter.Fill(ds, "Outstanding_table")
                connection.Close()
                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
asfahani

8/22/2022 - Mon
asfahani

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

ASKER
Hi. Thanks for the code but nothing seems to change with your code
ASKER CERTIFIED SOLUTION
asfahani

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
or
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

ASKER
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
asfahani

ur welcome dude.. glad it worked