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.|
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 (C#)” (special limited-time discount included in link).
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!
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.
Featured Online Courses:
- Boost SQL Server Database Performance with In-Memory OLTP
- Essential SQL Server Administration Tips
- SQL Server Fundamentals (SQL Database for Beginners)
- The Philosophy and Fundamentals of Computer Programming
- .NET Programming for Beginners: Windows Forms (C#)
- Introduction to Data Science and SQL Server Machine Learning
- Introduction to Azure SQL Database
- SQL Server 2019: What’s New
- Entity Framework: Getting Started (Ultimate Beginners Guide)
- How to Import and Export Data in SQL Server
- Get Started with SQL Server in 30 Minutes
- A Guide on How to Start and Monetize a Successful Blog
Check our other related .NET articles:
- .NET Programming for Beginners – Windows Forms (C#)
- Using ClickOnce for Deploying your .NET Windows Forms Apps
- There is no argument given that corresponds to the required formal parameter
- Using the C# SqlParameter Object for Writing More Secure Code
- Cannot declare instance members in a static class
- Cannot implicitly convert type ‘string’ to ‘System.Windows.Forms.DataGridViewTextBoxColumn
- The timeout period elapsed prior to obtaining a connection from the pool
- How to Connect to SQL Server from Visual C++
Subscribe to our newsletter and stay up to date!
Check out our latest software releases!
Easily generate SQL code snippets with Snippets Generator!
Convert static T-SQL to dynamic and vice versa with Dynamic SQL Generator.
Check our eBooks!
Rate this article:
Reference: SQLNetHub.com (https://www.sqlnethub.com)
Artemakis Artemiou is a Senior SQL Server Architect, Author, and a 9 Times Microsoft Data Platform MVP (2009-2018). He has over 15 years of experience in the IT industry in various roles. Artemakis is the founder of SQLNetHub and TechHowTos.com. Artemakis is the creator of the well-known software tools Snippets Generator and DBA Security Advisor. Also, he is the author of many eBooks on SQL Server. Artemakis currently serves as the President of the Cyprus .NET User Group (CDNUG) and the International .NET Association Country Leader for Cyprus (INETA).