Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot implicity convert type 'string' to 'System.Windows.Forms.ColumnHeader

I am new to Visual Studio 2010 C#. I already created a form. However, when I run the application there is an error occurred stating that "Cannot implicity convert type 'string' to 'System.Windows.Forms.ColumnHeader'". Can someone tell me what happened and how can I resolve this issue? Thanks.

enter image description here

like image 655
sean Avatar asked Oct 13 '11 03:10

sean


2 Answers

It seems that you've created a ColumnHeader with the name Name on the form which in turn hides the form property this.Name which is a string... that's the only scenario I can imagine leading to the error from the provided screenshot.
IF my assumption is right you can resolve that by changing that line to this.Name.Name = "ter";

like image 95
Yahia Avatar answered Oct 13 '22 16:10

Yahia


It seems that you've created a ColumnHeader with the name "Name". Please check if you have any controls with the name "Name".

Ex:-I had a DataGridView with column name "SrNo", "Name", "Age". I was getting the same error. Why bcoz of "Name".

Solution: Rename the DataGridView's ColumnHeader "Name" to other say "Person" or any thing other than "Name". But if you want to display the "Name" as Header text of DataGridView , you can keep the HeaderText as "Name".i.e.

Name: Person

HeaderText: Name

DataPropertyName: Person

Here DataPropertyName is optional. It is used if binding through collection as DataSource.

like image 21
Sudhanshu Shekhar Avatar answered Oct 13 '22 15:10

Sudhanshu Shekhar