思路:
1. 先在当前列的左边或者右边插入一个空列
2. 按行将当前列(被移动列)的值复制到新列
3. 移除当前列
代码如下:
/// <summary>
/// 获取当前列
/// </summary>
public DataGridViewColumn CurCol
{
get
{
if (neoDataGrid1.CurrentCell != null)
{
int col_index = neoDataGrid1.CurrentCell.ColumnIndex;
return neoDataGrid1.Columns[col_index];
}
return null;
}
}
/// <summary>
/// 按行将数据复制到新网格列
/// </summary>
/// <param name="colFrom">源列</param>
/// <returns>目地列</returns>
public DataGridViewColumn CopyDataGridColumn(DataGridView dgList, DataGridViewColumn colFrom, DataGridViewColumn colTo)
{
//DataGridViewColumn colTo = null;
foreach (DataGridViewRow dgRow in dgList.Rows)
{
foreach (DataGridViewCell dgCel