views:

409

answers:

2

I'm facing the need to enter "ragged" data in a WinForms application. Some columns are required for some types of entry lines and are not permitted on other entry lines, and the combo box data in later columns needs to vary based on the earlier columns.

My question is: is there a better way to handle data that isn't quite as regular as DataGridView is optimized to support. I know how to use "EditingControlShowing" to update the drop downs based on earlier entry info, but is this too much of a hack?

To visualize some examples of the data that needs to be entered:

Class  | Sub Class        | Company        | Bill Amount | Commission % 
ClassA | ClassA.Sub1      |                | $  1,500.00 |    12%
ClassB |                  |                | $    250.00 |     0%
ClassC |                  | ClassC.C1      | $    450.00 |     0%
ClassD | ClassD.Sub1      | ClassD.Sub1.C1 | $    800.00 |    12%

I'm using a dotted notation to indicate that the combo boxes are dependent on the items that are dotted before them (so ClassD.Sub1.C1 would be an item that looked up choices "WHERE Class = 'ClassD' and Sub = 'Sub1'".

I have hacked at the DataGridView to make it work, but it seems awfully ugly. Is there a better way? What control/method would you use to present data that varies from row to row in WinForms?

+1  A: 

How about SourceGrid? I haven't used it in production, but I played with it and it seems pretty flexible.

Marc Gravell
Checking it out now.
Godeke
+1  A: 

Maybe a repeater control would give you the flexibility you're looking for, http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx.

I've used it for custom user controls and it's worked great.