Populate DataGridView from 3 DataBound DataTables with relational links making dynamic matrix
Posted on 2009-04-07
I am using Visual Studio 2005, C#, .Net v2.0, DataSet controls to create XSD which write down to XML files for a Windows Form project. The XSD and XML files are all generated though Visual Studio... no database backends used.
I shall attempt to remove my real-world project names and make more general for ease of understanding. I am also going to simplify the table sizes.
I have three datatables of interest for this question and shall describe my desired outcome first.
I wish to have a DataGridView in a windows form.
The rows shall be peoples names, the columns shall be weekdays.
I wish the user of the DataGridView to be able to apply ticks to the matrix saying person1 did something on monday, wednesday etc and person2 did something on monday, tuesday and sunday etc.
The persons name and quantity of people shall be within Table1.
The days and quantity of days shall be within Table2 (maybe days is a bad example but it's a list which can grow and shrink)
There shall be a Table3 which contains the 'ticks'.
Table1 Columns: NameID[autonumber], Name[string], TicksID[int][unique]
Table2 Columns: DaysID[autonumber], Day[string]
Table3 Columns: TicksID[int],DaysID[int]
I have reservations as to if this is the correct way to implement my task... I welcome alternatives.
I also have no idea how I dynamically populate the DataGridView and bind the data.
I cannot be the first to come up with this kind of matrix requirement so perhaps there is more than one way to skin a cat?
Code snippets would be most welcome and I'd love some help with this problem.
I hope I have explained my situation sufficiently; if not please request additional information.
Thank you for your time.