Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag 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)
Avatar of asfahani
asfahani

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

ASKER

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

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
ur welcome dude.. glad it worked