Question : Reorder Columns in a DataGrid

Hi,

Can anyone tell me how I can allow a user to drag and drop columns to reorder them in a DataGrid?
Thanks

Answer : Reorder Columns in a DataGrid

Here we go: :)

        Dim ts As New DataGridTableStyle
        ts.MappingName = [NameOfDataTable]

        Dim colPrice As New DataGridTextBoxColumn
        With colPrice
            .Width = 120
            .MappingName = "price" ' Or whatever the column is called...
        End With ' colPrice
        ts.GridColumnStyles.Add(colPrice)

        ...

        [DataGrid].TableStyles.Add(ts)

NOTE: You can also set the alignment, etc...  Just examine the properties of the DataGridTextBoxColumn... :)

Jake
Random Solutions  
 
programming4us programming4us