c# - Keep order while columns.AddRange() in datagridview -


this code userdynamicsetscontrol

this.datagridview1.columns.addrange(new system.windows.forms.datagridviewcolumn[] { this.columnsa,this.columnb,this.columnsc,this.columnd}); 

and second solution (i use interchangeably)

var list= new system.windows.forms.datagridviewcolumn[] { this.columnsa,this.columnb,this.columnsc,this.columnd};  foreach (datagridviewcolumn datagridviewcolumn in list)             {                 datagridview1.columns.add(datagridviewcolumn);             } 

those codes works, add columns in wrong order , e.g. columnb,columnc,columna,columnd.

how make sure column in order?

have checked displayindexs on columns adding? ensure columna has displayindex of 0, , column b 1 etc.

link msdn regarding displayindex http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.displayindex.aspx

not 100% sure though, im used working xceed datagrid not micorsoft one.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -