Thursday, July 3, 2014

InvalidCastException? Are you sure? Why?

I've created a class here for a ColumnHeader:



public class ColHeader : ColumnHeader
{
public bool ascending;
public ColHeader(string text, int width, HorizontalAlignment align, bool asc)
{
this.Text = text;
this.Width = width;
this.TextAlign = align;
this.ascending = asc;
}
}



And when I say this:



ColHeader clickedCol = (ColHeader)this.listView1.Columns[e.Column];



It says I can't convert the ColHeader class into a ListView.ColumnHeader. Why is this? I'm just starting to learn classes so I don't really understand.




“It is not that I'm so smart. But I stay with the questions much longer.” ― Albert Einstein


No comments:

Post a Comment