Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I have a number of objects I need to sort and to filter in order to get the best match for the current situation.

In my old VB6 app I used a disconnected recordset. Basically because it allowed me to filter the records and sort the result. The record was added and removed dynamically and never saved.

 

In my new design I'm not sure how to best change this. It dosn't seem too clever to use old ADO when there's so many new options. Arrays, Lists, Collections all of them is sortable, no?

 

Any ideas of the best way to solve this?

Regards

/Kejpa

Posted
For custom sorting rules, read up on the IComparer and IComparable interfaces. If you'd prefer to do ADO-style sorting and filtering, you can use a DataView.
Posted

Thanx JABE,

I'm still not satisfied though. I know I can use collections, Arrays, lists (and now DataViews) but I'm not sure which is the best approach.

 

In VB6 you couldn't sort anything but Recordsets without creating your own sort routines, now that you can I'm curious to what the benefits and sraw backs are of the different containers.

Point of directions wanted.

 

Regards

/Kejpa

Posted
By implementing IComparer or IComparable, a class can define its custom sorting rules. The question of whether you'll use a collection, array, lists or whatever to contain your class instances is an altogether different issue. AFAIK, only Array and ArrayList implement the Sort method so this in effect limits your choices. I brought up using DataView as an alternative since this is the most convenient approach if you're working w/ database records that need to be sorted and/or filtered.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...