Windows Forms - DataGridView Button Columns Not In Order
The problem was that a Button column would refuse to be in the right place. The other columns would order properly but not that button column. So the idea is to use this Display Index as stated in the msdn link below. One other thing that needs to be done is to set the AutoGenerate Columns property to false as well.
dg.datasource = dt
dg.AutoGenerateColumns = False
and then
dg.Columns("col_name").DisplayIndex = 0
etc
https://msdn.microsoft.com/en-us/library/wkfe535h(v=vs.100).aspx
https://social.msdn.microsoft.com/Forums/en-US/e417afad-320b-49d8-9e00-3fec5f360fde/datagridview-displayindex-doesnt-keep-positions?forum=winformsdesigner
dg.datasource = dt
dg.AutoGenerateColumns = False
and then
dg.Columns("col_name").DisplayIndex = 0
etc
https://msdn.microsoft.com/en-us/library/wkfe535h(v=vs.100).aspx
https://social.msdn.microsoft.com/Forums/en-US/e417afad-320b-49d8-9e00-3fec5f360fde/datagridview-displayindex-doesnt-keep-positions?forum=winformsdesigner
Comments
Post a Comment