Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27207

Datatable Sorting

$
0
0
Hi again

So i have a datatable and its sorted like this.
Code:

playerOleDbDataAdapter1.Fill(PvpleaderboardDataSet.Players)
playerDataGrid.Sort(playerDataGrid.Columns(0), ListSortDirection.Descending)

And in the dgv the records displayed as it is intended to.

I want to export the datatable to a text file but when i do the output is still unsorted. The output text writes the records in the order they were added. How do I export it in the same order as it was sorted in?

Code:

Dim writer As New StreamWriter("C:\Leaderboard\Leaderboard.txt", False)
        Dim num As Integer = 1
        For Each row As DataRow In PvpleaderboardDataSet.Players.Rows
            writer.Write(String.Format("{0,-10}{1,-10}{2,-30}{3,-30}{4,-30}{5,-15}{6,-10}{7,-10}", num, row("Rating"), row("Player Name"), row("Account"), row("Profession"), row("Total Played"), row("Wins"), row("Losses")))
            writer.WriteLine()
            num = num + 1
        Next
        writer.Close()


Viewing all articles
Browse latest Browse all 27207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>