« WPF: Bottom dwelling with an ItemsControlMSDN Roadshow and food, Zi Makki style »

Cross tables in Windows Forms - data binding magic

16/03/07

Permalink 05:55:18 pm
Categories: General, Programming, .NET

Cross tables in Windows Forms - data binding magic

I have this sample from a recent talk at Basta! conference in Germany, which shows (among other things) how to bind a cross table to a DataGridView (the standard .NET 2 data grid). A cross table is basically the result of transposing some data and using one of the fields for a second dimension.

The sample I have works on two tables of data. It doesn't actually use a database and the reference that points from the list of votes to that of features is implemented as an object reference, but the relationship is like this:

 Now, let's assume there's this data in the two tables/lists:

Features
ID Name
1 Synthesize out-of-the-box supply-chains
2 Syndicate vertical mindshare
  

Votes
ID Feature_ID Year Priority
1 1 2004 30
2 1 2005 40
3 1 2006 70
4 2 2004 70
5 2 2005 60
6 2 2006 30

In a cross table the same data could look like this:

Feature/Year 2004 2005 2006
Synthesize out-of-the-box supply-chains 30 40 70
Syndicate vertical mindshare 70 60 30

This is exactly the kind of transformation demonstrated in my sample. Now, there are a number of other things in that program, so don't be confused. I suggest you focus on the workings of the VoteValuePropertyDescriptor class.

Here's the download: FeatureVoting.zip

 

1 comment

Comment from: Onno v L [Visitor] Email
Onno v LVery nice to see what can be done with a datagridview and appropriate propertydescriptor. However could you tell me how to do this for two or three linked dataTables instead of two collections?
10/04/07 @ 20:06

Leave a comment


Your email address will not be revealed on this site.
(Line breaks become <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)
Please complete the song title below. Hint: enter 's', 'a', 't', 'i', 's', 'f', 'a', 'c', 't', 'i', 'o', 'n'
antispam test

Enter your email address:

Search

Oliver
MVP logo
May 2012
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31