views:

227

answers:

1

I am using Grammarian's ObjectListView. I changed my old listviews to that, but all I do is to fill in items. But when the app starts up and my mouse is over the listview, it immediately throws an exception for:

System.InvalidCastException was unhandled
  Message="Unable to cast object of type 'System.Windows.Forms.ListViewItem' to type 'BrightIdeasSoftware.OLVListItem'."
  Source="ObjectListView"

How to fix this?

Also I use Win7 if that's important.

EDIT:

I use a dictionary. It looks like I need to use the SetObjects method instead of adding items.

Ok this is great, but I am just using the dict.Value collection. I don't want to modify the data through listview, only show. So I have only 1 column and list everything there which are strings. Is this possible?

I would appreciate a small sample.

+1  A: 

You are right -- you should be using the SetObjects() method rather than adding ListViewItems. In an ObjectListView, there should never be ListViewItems. The control keeps track of more information and so needs more than ListViewItems provides.

You might want to read the Getting Started page of the website, especially the Unlearn you must section.

ObjectListView does have its own forum, if you want to ask questions there.

Grammarian