I have quite a few places where I need to bind form controls directly to a backing database. I'm using LINQ to DataSet to do this.
For example, I have a ComboBox with entries filled in by a database query. The problem is of course that all of my data uses numerical IDs and I need to do a table query to translate this into user-readable options.
Normally I would just join the second table and use the combobox DisplayMember to point at the user-readable string column. This doesn't work because after using join or any projections on the query you're (understandably) unable to convert that query into a DataView.
It's hard to believe that this problem isn't run into by everyone who uses DataView. Is there any way to override my form controls' behavior to make them display a function of their value? Like if their Value is v, then they display SomeMethod(v)?
I don't believe what you are trying to accomplish is possible by means of DisplayMember. Its a property, that's how it was designed. However, there are a few other means to accomplish what you want.
1) You could wireup to the ComboBox's Format event. This is the ideal place to change your databound items into human-readable items for display, and really is exactly what you want.
2) You could use LINQ to SQL classes instead, and override the .ToString() portions in the partial classes to display the data how you want. When you databind to a LINQ to SQL object the ComboBox will display the string value of that object.
Since you are already using LINQ to DataSet, I would just wireup to the Format event, though.