我正在尝试在datagridview中显示一个足球联赛表。我的代码从ms访问中获取每列的数据,并将其显示在datagridview中。我想根据“pts”列的值对行进行排序。我尝试使用BindingSource.Sort =“pts”,但这没有任何效果。 继承了我的一些代码,任何帮助都会受到赞赏!
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)处理MyBase.Load OleDbConnection1.Open() Dim命令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