Exploring Secrets of the .NET DataGridView and Dynamic Data Manipulation
Find out how to use a single DataGridView to display dynamic queries, adjusting columns automatically, and how to format individual cells exactly the way you want users to see them.
by Michael Sorens
June 22, 2007
ith the visual designer of Visual Studio 2005 it's simple and straightforward to stir together a database connection, a SQL query, and a DataGridView control to get a Windows WYSIWYG application. Toss in a few buttons, a dollop of labels, and a text box or two, and you can provide a functional application for your users without too much effort. There are two important aspects of database programming that cannot be covered by the basic designer mechanisms, however.
The first is when you want to use a single DataGridView to display completely unrelated query results in different circumstances—queries that may have different data types for each column or even a different number of columns. In a sample application that contains only an edit window and a DataGridView, you will see how to let users arbitrarily display the results of any queries they wish in a single DataGridView that adapts dynamically to the data display requirements for any particular query.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!