0

In C# 4.0 winform application. I have a DataGridView with some columns, it's AllowUserToOrderColumns = true, user can change columns position by dragging it.

When user dragged a column i want to know which column is dragged and where it is now.

leppie
  • 115,091
  • 17
  • 196
  • 297
Haider Ali Wajihi
  • 2,756
  • 7
  • 51
  • 82

1 Answers1

2
    private void dataGridView1_MouseUp(object sender, MouseEventArgs e)
    {
        var hitTest = dataGridView1.HitTest(e.X, e.Y);
        string colDragged = dataGridView1.Columns[hitTest.ColumnIndex].Name;
        MessageBox.Show("Column Dragged is " + colDragged.ToString());
    }
spajce
  • 7,044
  • 5
  • 29
  • 44