Hi Chris:
You have kind of a unique problem and there are a few ways you can handle
this. You could create another column and at the onset, set each value to a
sequential numeric position. You could then sort on this column. If you
already have an account number or some other number you could make this
number the same so it sorted the same way. You could make this number in the
new row the same as the row above it. The dataview sorts automatically so
it'd add this next to the first number. You'd probably need some other
tweaks and no matter what it would probably be a bit ugly. If you want to do
something cool..
Basically what we want in an Insert Method for the Datatable's RowCollection
but we don't have one. However, the nice thing about bindings is that
anything that Implements IList can be used to bind the grid. So you could
create your own object, use the values from the rows in the object and bind
to your IList object. If you used an Array or an ArrayList or a whole slew
of other things (I belive CollectionBase has a Remove and RemoveAt) but this
gives you the ability to insert at a particular position, which is
essentially what you want. Furthermore ArrayLists for instance have a .Sort
method and although it may or may not give you what you want by default, you
can use a IComparer object to finely tune your sort.
The main point is that with a little work, you can do just about anything
you want most of the time. In this instance, implementing IList and
ICompare in a custom object or collection will allow you to not only bind a
grid to it, but create any type of custom sorting you may need. By using a
Arraylist or an array in your implementation you can take advantage of the
Insert method (or depending on what object you use InsertAt ) to specify a
position To be honest what you actually want is more on the lines of an
InsertAt but that's really not the point, I just wanted to illustrate that
with the implementation of a few interfaces, you can do a whole heck of a
lot.
Cheers,
Bill
--
W.G. Ryan, eMVP
http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp