Question

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.

Était-ce utile?

La solution

    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());
    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top