开发者

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.

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


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";


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.


Are you sure you don't want .Text instead of .Name?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜