Pregunta

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.

¿Fue útil?

Solución

    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());
    }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top