GenericDataGridView is a new control which is more flexible for coding than a simple
datagrid. However, there are a lot of developers who are facing difficulties about
DataGridView Calendar, Mask, ComboBox and also Validations. Actually,
GenericDataGridView does not support such important properties.
Generic Data Grid View is a user control which can be really helpful for:
- Adding a
- Adding a calendar to
- Adding a
DataGridView MaskedTextBox column)
- Saving any edited row with automatic created queries.
While I was coding Generic
DataGridView, I tried to put all important features which can be required for a project. However, these are unlimited. You can add more properties and methods in order to improve it.
After placing the
GenericDataGridView(GDGV) in your project, you should set some properties.
Picture 1 - Properties
DataColumns should be set in design time or in
Form_Load such as above and below:
GenericDataGridView1.DataColumns = "OrderID,CustomerID%,OrderDate%,
The column which has a
string or date type should be written with
% to distinguish. It is necessary for creating DML (Save and Update Queries). And also the first column should be an identity column. The
Northwind Database and the
Orders table has been selected to demonstrate the example project. In addition to this, the first column (
OrderID) must be an identity column.
GenericDataGridView1.DataConnection = "Integrated Security=SSPI;
Persist Security Info=False;Initial Catalog=Northwind;Data Source=localhost"
GenericDataGridView1.DataColumnsTable = "Orders"
There are some other definitions to be set in
- FillAll: to fill
AddCombo: to add a
- AddValidation: to add validation to Columns
- AddMask: to place a mask to columns
- AddCalendar: to add a
Picture 2 - Form Load
Picture 3 - Add Combo
Picture 4 - Add Validation
Picture 5 - Add Calendar
Picture 6 - Add Mask
Picture 7 - Form Load
Picture 8 - Calendar Column
Picture 9 - Combo Column
Picture 10 - Validation
Picture 11 - MaskedText Column
Picture 12 - Row Saved
P.S.: There can be some bugs related with the properties of the database server and regional settings of the client such as datetime and (, or .) which can be fixed easily. Please feel free to ask any questions. The source code of the project has
GenericDataGridView Control (C#), VB.NET Project to demonstrate the control and C# project to demonstrate the control.
Bug Fix Version
Firstly, thanks for your nice contributions. It was almost year ago that I posted the article, now the hit is 70.000. Every day I am receiving new emails with questions and comments from all over the world. I have already fixed some bugs of this version, I am sending a new post with a delay of 3 months.
The bug fix version includes 2 points:
- Null Column problem of dates, via adding datecolumns such as "
DataColumns property of GDGV (
GenericDataGridView). This problem is going to be solved. You will find one example in the source code.
DateFormat problem, every country has got regional settings and database settings, that is why the new property "
DBDateFormat" is defined. You can simply add it.
GenericDataGridView1.DBDateFormat = "MM/dd/yyyy"
You will find one example in the source code.
I hope you will accept my excuses for delay of bug fix because of new component work. I have started to work on a new component which is
GenericWebDataGrid control. As you know, web components are getting more attention after the client side programming has become popular. My new toy is working also on the client side. It is fast for updates and inserts (database works) and it is fast for development. I hope I will publish it by the end of this year. It is going to be free and open source.
GenericWebDataGrid was published. Please check my other articles.
Please don't hesitate to ask any questions anytime. You can email me at email@example.com.