Cannot implicitly convert type ‘string’ to ‘System.Windows.Forms.DataGridViewTextBoxColumn

When developing a .NET application (i.e. in C#), under certain circumstances, you might get the error message: 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 - SQLNetHub Article
Example of Exception in Visual Studio when Using the Reserved Word “Name” as a DataGridView Column Name.

 

Why you got the implicit conversion error

If you get the above error, then you have most probably set as a column name for one of your datagridview column the reserved word ‘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.

 


Get Started with .NET Programming Fast and Easy!

Check our online course titled “.NET Programming for Beginners – Windows Forms with C#.
(special limited-time discount included in link).

.NET Programming for Beginners: Windows Forms (C#) - Online Course

Learn how to implement Windows Forms projects in .NET using Visual Studio and C#, how to implement multithreading, how to create deployment packages and installers for your .NET Windows Forms apps using ClickOnce in Visual Studio, and more! 

Many live demonstrations and downloadable resources included!

Learn More


How to resolve the issue

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.

 

Recommended Online Courses:

 

Check our other related .NET articles:

 

Subscribe to our newsletter and stay up to date!

Check out our latest software releases!

Check our eBooks!

 

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)

Loading...

Reference: SQLNetHub.com (https://www.sqlnethub.com)

© SQLNetHub