Cannot implicitly convert type 'string' to 'System.Windows.Forms.DataGridViewTextBoxColumn

If you get the above error message when developing a .NET application, then you have most probably set as a column name for one of your datagridview column the reserved word 'name'.

Cannot implicitly convert type 'string' to 'System.Windows.Forms.DataGridViewTextBoxColumn
Example of Exception in Visual Studio when Using the Reserved Word "Name" as a DataGridView Column Name.

If you do this, then the compiler finds a conflict between the assignment of the form's name and the DataGridview's column name.

To resolve this issue just change the name of the DataGridView's column to something else instead of "name".

There is a reason there are reserved words not only in .NET byut in many other development platforms as well (i.e. SQL Server, etc.).

To this end, please make sure that you are not using any reserved words in your development work because if you use them, there is always the risk of a conflict with system routines like the above example.

Check this MSDN article for information about the words reserved by the linker.

The SQL Server and .NET Hub

Reference: The SQL Server and .NET Hub (http://www.sqlnethub.com)

For more articles click here!


Labels: ,