سؤال

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.

هل كانت مفيدة؟

المحلول

    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());
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top