Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi,

I am using ListView Control.I created 4 Columns .when i gave a try to run my form,I got an error:
"Cannot implicitly convert type 'string' to 'System.Windows.Forms.ColumnHeader."

The error is in this code snippet of Form.Designer.cs
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(469, 359);
this.Controls.Add(this.listView1);
this.Name = "Form1";  ' --- here i got an error ---
this.Text = "ListView Demo Form";
this.ResumeLayout(false);

Could anyone explain about this error?

Regards,
Chaithu
Posted
Updated 19-May-11 21:42pm
v3
Comments
Member 13459339 6-Feb-18 3:31am    
Please update the solution .

Does your listview have a column named "Name" or some other control with the name "Name"? Try changing it and have another go. Have a look at the link to another forum with a similar question.

http://bytes.com/topic/net/answers/602612-cannot-implicitly-convert-system-windows-forms-columnheader[^]

Good luck!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-May-11 4:32am    
Text, not Name. Please, don't mislead OP.
--SA
E.F. Nijboer 20-May-11 9:32am    
M.CHAITHANYA reports that changing the text of columnheader from "Name" to "Name1" did the trick so my answer wasn't misleading at all but actually very helpful.
Sergey Alexandrovich Kryukov 20-May-11 23:42pm    
Thanks for this note. I now see where I was wrong, sorry for my mistake. I re-voted by 5.
--SA
E.F. Nijboer 22-May-11 9:01am    
Thanks! :-)
It sounds like you just need to use the Text property in that Line.

Hope this will solve your problem.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-May-11 4:32am    
Text, not Name -- you're right, my 5.
--SA
[no name] 20-May-11 4:36am    
Thanks SA
M.CHAITHANYA 20-May-11 5:17am    
Hi,
I got the solution,the problem is i have used Columnheader text as "Name"...this was creatign problem.I changed it "Name1".Now it's working fine.
[no name] 20-May-11 8:38am    
Fine.
Sergey Alexandrovich Kryukov 20-May-11 23:34pm    
Never use IDs named like label1 text3, etc. This actually violates (good) Microsoft naming conventions (FxCop won't pass it). Always give semantic names.
--SA
 
Share this answer
 
Comments
CHill60 4-Aug-13 13:31pm    
I think he got the idea 2 years ago
PictureBox pictureBox1 = new PictureBox();
public void CreateBitmapAtRuntime()
{
pictureBox1.Size = new Size(210, 110);
this.Controls.Add(pictureBox1);

Bitmap flag = new Bitmap(200, 100);
Graphics flagGraphics = Graphics.FromImage(flag);
int red = 0;
int white = 11;
while (white <= 100) {
flagGraphics.FillRectangle(Brushes.Red, 0, red, 200,10);
flagGraphics.FillRectangle(Brushes.White, 0, white, 200, 10);
red += 20;
white += 20;
}
pictureBox1.Image = flag;

}

Try this,

Its just that its not the same property

after this conversion you should be up and running for sure
 
Share this answer
 
Comments
CHill60 22-Feb-14 8:19am    
The problem was solved 2 and a half years ago and the OP actually confirmed it. This has got nothing to do with the question
Dr Drastic 24-Feb-14 2:07am    
I apologize,

I had multiple windows open and pasted into the wrong one.

That's why it has nothing to do with the question.
That should be runtime exception(you make to change the Form name while sometime) ... You Make to delete that code(That No Problem in your output).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900