c# - VB.NET Custom DataGridView control - Duplicate columns at runtime? -


i making control inherits datagridview. adding columns programmaticly in controls constructor, so.

public sub new()     mybase.new()  'this call required component designer. initializecomponent()  optionsform = new frmoptions(me)  'note: add columns programmatically rather via designers properties window, or duplicated when added form! dim colipaddress, colport, colstatus, colspeed, colcountry new datagridviewtextboxcolumn     colipaddress.headertext = "ip"     colport.headertext = "port"     colstatus.headertext = "status"     colspeed.headertext = "speed"     colcountry.headertext = "country"      columns.addrange({colipaddress, colport, colstatus, colspeed, colcountry})      rowcount = 1 me.refresh() end sub 

when add control form, displays columns correctly. during runtime, columns duplicated. added if statement columns added if current column count 0, still no avail.

anyone know whats going on? thanks! :)

set autogeneratecolumns property on datagridview control false:

datagridview1.autogeneratecolumns = false; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -