C# DataGridView 动态添加列和调整列顺序

https://yq.aliyun.com/articles/421700

 

 

// DataGridView1ColumnDisplayIndexChanged事件处理方法
private void DataGridView1_ColumnDisplayIndexChanged(object sender,
    DataGridViewColumnEventArgs e)
{
    Console.WriteLine("{0} 的位置改变到 {1} ",
        e.Column.Name, e.Column.DisplayIndex);
}

 

 

  this.Dgv.Columns.Add("状态", "状态");
            this.Dgv.Columns.Add("原因", "原因");
            this.Dgv.Columns["状态"].DisplayIndex = 0;
            this.Dgv.Columns["原因"].DisplayIndex = 1;

转载于:https://www.cnblogs.com/LuoEast/p/10751834.html

你可能感兴趣的:(C# DataGridView 动态添加列和调整列顺序)