Do not want to read all the following? Then go right to the download and test drive the project. There is nothing truly new here but then again there might be something that gets you thinking in a different direction.
Requires VS2008 or higher using Framework 3.5 or higher
The purpose of this code bank post is to provoke thoughts in regards to utilizing language method extensions using as an example creating a master/detail which most examples found on the web are very simple (which is not bad) yet do not explain how to work your data manually.
Many developers will add a data source to a project, drop various data components onto forms and go about developing their solution. This works fine yet there are times with complex application this does not work. Also there are solutions this is not possible, for example, IBM data provider is not up to par with MS-SQL server in regards to helper components or do not have support say for Data Context.
With this in mind the attached project show a more manual approach to setting up a master/detail relationship between two tables. Also there is several language extension methods included which do not add anything other than removing the complexities of operations into wrappers. These wrappers for some will make it easier to get results rather than attempting to remember “how do I do that?”
What can make a difference when enclosing (at least for me) logic into wrappers which can be functions, procedures or functions and procedures into extension methods is the Intellisense description text. With that said if these methods work for you make sure the descriptions which appear when using them makes sense. Also if the method name does not make sense to you then by all means change the name.
To being, compile the project then run it. You will see two DataGridView controls, top for master and bottom for detail rows. As you scroll through the master DataGridView note that the default child row is displayed to the editor’s output window. This demonstrates getting back information about the current detail row using a language extension method which is not pretty so we make it pretty by using an extension. As you scroll through the Details DataGridView the same logic is used for scrolling in the master DataGridView, show the current row items.
Speaking of making things pretty, there are two DataGridView language extension methods. The first is project specific which hides the ID columns in both DataGridView controls. The second uses the underlying DataTable column captions for their DataGridView column header text.
Caveat: If you want to place break points in the code you will need to comment out the following attribute for any function or procedure you are going to trace into