Sortable Binding List for Generics

///Sortable Binding List for Generics

The Saga of Sortable Binding List for Generics and How the Mother Ship doesn’t give you Tomatoes

The only Microsoft assembly\namespace where you will find a sortable binding list for generics is in Microsoft.SqlServer.Management.Controls

Um mm, say what?

I remember this when generics were first introduced and wondered why.  I also found a chunk of code I have had around for a while that is nicely written (slightly modified to meet my coding standards) but because I hadn’t looked in the latest BCLs, I figured I should take a look. Frankly, even though the code I am going to share never has caused any issues for me, I prefer a Microsoft implementation of a data structure almost every time. Their QA in this area is really amazing.

So, time to go spelunking through the dark corridors of MSDN and the lightness and joy of Stack Overflow to see if the BCLs include a sortable binding list for generics.

No tomato in that garden but come on, really?

So, I have dotPeak and so should you because it’s free and made by JetBrains, one of my favorite companies.  Or .NET Reflector, which is really quite good but isn’t free. There is also ILSpy, which is good as well.  If you are like me, you have all of them because you like tools.

Anyway, point being is I cannot find a sortable binding list for generics in the Microsoft stack.

While cooking dinner (Mongolian beef with brown rice), I load the entire global assembly cache into dotPeak and wait for it…

There is one clear as day since 3.5 even!  Where have I been?!

Sortable Binding List

Not really thinking clearly because I am doing dinner at the same time, I go back to Visual Studio, check to ensure I have the correct usings for System.Data.Linq and try to use the type. No tomato in that garden either!  But why not? I hadn’t looked closely enough at is protection level:

Okay, Microsoft. I worked there for years. It is my alma mater. I love the company. But this is really dumb.
Here is a complete listing with the name changed so as to not collide with the sortable binding list I am going to use:

I cleaned it up a bit and used some of the C# 6.0 language features, but otherwise, it is functionally identical to the internal type in the Linq namespace.  I don’t see why this shouldn’t be made public but that it doesn’t make me nervous so I am going to stick with what I have used over the years.  The original is here: http://martinwilley.com/net/code/forms/sortablebindinglist.html.  My slightly touched up version for your viewing and hopefully practical pleasure is here:

So it was a minor diversion but I am done with work and on to my “play” projects so I didn’t really mind. Take aways for me are: don’t expect the mother ship to give tomatoes. Use your tools but use them correctly. Don’t eat and code. And finally, if it ain’t broke don’t fix it. Maybe that’s why Microsoft never shipped a public version of the type.  They have budgets too you know.  I can see the program manager and the Linq dev manager sitting there talking about it and saying “don’t put it in, that dude Martin has one that everybody uses anyway.”

By | 2017-11-17T11:30:35+00:00 May 22nd, 2017|Categories: .NET, Development|Tags: , , , |Comments Off on Sortable Binding List for Generics

About the Author:

Thanks for taking the time to read my profile and presumably my posts. I am a big city person living in a tiny town that offers no distracts from my passion: Creating software that helps others be more productive, happy, and enhances their work or personal life. I am a life-long learner, builder, writer, tinkerer, and when duty calls, an focused engineer and project manager.