Diarmuid Naughton
Diarmuid Naughton

Reputation: 27

Bindingsource sort by column value, datagridview

I am trying to display a football league table in datagridview. my code gets that data for each column from ms access and displays it in datagridview. I want to sort rows according to the value of the "pts" column.I've tried using using BindingSource.Sort = "pts" but this has had no effect. heres my some of my code any help would be appreciated!

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load OleDbConnection1.Open() Dim command As OleDbCommand = New OleDbCommand() command.Connection = OleDbConnection1 command.CommandType = CommandType.StoredProcedure command.CommandText = "Query7"

    Dim objReader As OleDbDataReader = command.ExecuteReader

    TeamBindingSource.Clear()


    Do While objReader.Read()

        Dim tm = objReader("teamname")

        Dim mp, w, d, l, f, a, p As Integer

        mp = Getgamesplayed(OleDbConnection1, tm)
        w = GetGamesWon(OleDbConnection1, tm)
        d = GetGamesdrawn(OleDbConnection1, tm)
        l = 0
        f = GetGoalsScored(OleDbConnection1, tm)
        a = GetGoalsConceeded(OleDbConnection1, tm)
        p = 0
        Dim team As New Team(tm, mp, w, d, l, f, a, p)
        TeamBindingSource.Sort = "pts"
        TeamBindingSource.Add(team)

    Loop
End Sub

Upvotes: 0

Views: 4674

Answers (1)

Shrieks
Shrieks

Reputation: 141

From what I understand, this is Object Data Source where you need to implement your own sorting.

See if this helps: Sorting Objects in Binding list

Upvotes: 0

Related Questions