Can I Order My Collection?

  • Thread starter Thread starter Patrick A
  • Start date Start date
P

Patrick A

All,

If I want to build a collection in a specific order, and I'm filling
it from a TableAdapter whose source query I can not change, how would
I put it in the order of one of the columns in the underlying query?

I've tried various things as spelled out in my book and other sources,
but nothing seems to "recognize" a column name.

Here's what I have;

Me.QRY_ButtonsTableAdapter.ClearBeforeFill = True

Me.QRY_ButtonsTableAdapter.Fill(Me.L55TimerDataSet.QRY_Buttons)
Dim Row As Integer = 0
Dim ButRecds =
L55TimerDataSet.Tables("QRY_Buttons").AsEnumerable
Dim sortedButRecds = From a_row In ButRecds _
Select a_row _
Order By TimerPos Descending

Suggestions?

Thanks,

Patrick
 
Patrice,

Thanks for your reply.

It worked!

Me.QRY_ButtonsTableAdapter.ClearBeforeFill = True
Me.QRY_ButtonsTableAdapter.Fill(Me.L55TimerDataSet.QRY_Buttons)

Dim Row As Integer = 0
Dim ButRecds =
L55TimerDataSet.Tables("QRY_Buttons").AsEnumerable.OrderBy(Function(c)
c.Field(Of String)("butLabel"))
Dim sortedButRecds = From a_row In ButRecds _
Select a_row

*************

Patrick
 
Back
Top