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
Post a Comment