PC Review


Reply
Thread Tools Rate Thread

Can I Order My Collection?

 
 
Patrick A
Guest
Posts: n/a
 
      29th Mar 2010
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
 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      30th Mar 2010
Hello,

> Dim ButRecds =
> L55TimerDataSet.Tables("QRY_Buttons").AsEnumerable
> Dim sortedButRecds = From a_row In ButRecds _
> Select a_row _
> Order By TimerPos Descending


Try the doc at :
http://msdn.microsoft.com/en-us/library/bb386910.aspx (the compiler needs
some info about your columns).

Another option could be to define the sort order of the DefaultView :
http://msdn.microsoft.com/en-us/libr...view.sort.aspx

--
Patrice



 
Reply With Quote
 
Patrick A
Guest
Posts: n/a
 
      30th Mar 2010
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Sort order of a collection simon Microsoft Excel Programming 3 3rd Mar 2007 06:19 AM
key/value collection that allows key string to be updated and retains collection item entry order dx Microsoft Dot NET Framework 2 25th Sep 2004 05:51 PM
Collection order Mike Microsoft C# .NET 8 10th Jun 2004 02:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:17 PM.