private void toolLeft2_Click(object sender, EventArgs e)
{
int selcol = DBGrid2.CurrentCell.ColumnIndex;
int selrow = DBGrid2.CurrentCell.RowIndex;
DataGridViewColumn col = (DataGridViewColumn)DBGrid2.Columns[selcol].Clone();
DBGrid2.Columns.Insert(DBGrid2.CurrentCell.ColumnIndex - 1, col);
DBGrid2.Columns.RemoveAt(selcol + 1);
DBGrid2.CurrentCell = DBGrid2.Rows[selrow].Cells[selcol - 1];
}
private void toolRight2_Click(object sender, EventArgs e)
{
int selcol = DBGrid2.CurrentCell.ColumnIndex;
int selrow = DBGrid2.CurrentCell.RowIndex;
DataGridViewColumn col = (DataGridViewColumn)DBGrid2.Columns[selcol].Clone();
DBGrid2.Columns.Insert(DBGrid2.CurrentCell.ColumnIndex + 2, col);
DBGrid2.Columns.RemoveAt(selcol);
DBGrid2.CurrentCell = DBGrid2.Rows[selrow].Cells[selcol + 1];
}
private void DBGrid2_SelectionChanged(object sender, EventArgs e)
{
if (DBGrid2.CurrentCell == null) return;
if (DBGrid2.CurrentCell.ColumnIndex <= 1 || DBGrid2.CurrentCell.ColumnIndex >= DBGrid2.ColumnCount - 1)
{
toolLeft2.Enabled = false;
toolRight2.Enabled = false;
}
else if (DBGrid2.CurrentCell.ColumnIndex == 2)
{
toolLeft2.Enabled = false;
if (DBGrid2.CurrentCell.ColumnIndex == DBGrid2.ColumnCount - 2)
toolRight2.Enabled = false;
else
toolRight2.Enabled = true;
}
else
{
toolLeft2.Enabled = true;
if (DBGrid2.CurrentCell.ColumnIndex == DBGrid2.ColumnCount - 2)
toolRight2.Enabled = false;
else
toolRight2.Enabled = true;
}
}