当AllowUserToOrderColumns = true时,如何在datagridview中获取拖动列

时间:2013-06-10 10:53:43

标签: winforms c#-4.0 datagridview drag-and-drop datagridviewcolumn

我有一个Windows窗体应用程序,其中我有一个带有AllowUserToOrderColumns = true的datagridview,然后用户通过拖放更改列顺序。

我如何知道拖动了哪一列?

1 个答案:

答案 0 :(得分:0)

当您设置 AllowUserToOrderColumns = true 时,您将知道 ColumnDisplayIndexChanged

中的列名称
Private Sub Datagridview1_ColumnDisplayIndexChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewColumnEventArgs) Handles dgvGuru.ColumnDisplayIndexChanged

     MsgBox(e.Column.Name)

End Sub