ObjectListView投异常(点击测试) [英] ObjectListView cast exception (for hit testing)

查看:246
本文介绍了ObjectListView投异常(点击测试)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的文法的ObjectListView。我改变了我的老列表视图到这一点,但我要做的就是填写项目。但是,当应用程序启动时,我的鼠标移动到列表视图,它立即抛出一个异常:

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?

另外我用Win7的,如果这是非常重要的。

Also I use Win7 if that's important.

编辑:

我用一本字典。它看起来像我需要使用添加项目的SetObjects方法来代替。

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

确定这是伟大的,但我只是用了dict.Value集合。我不想通过列表视图修改数据,只能说明。所以,我只有1列,并列出一切有哪些是字符串。这可能吗?

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?

我会AP preciate一小部分。

I would appreciate a small sample.

推荐答案

在问候文法的回答,他们不告诉你的是这一点。

In regards to Grammarian's answer, what they do not tell you is this.

他们告诉你,你只需要一条线来激活它,但你会发现这是一个头痛的很多的更多的工作,那么它的价值。我的的建议你坚持的正常的ListView ,否则你会发现自己写1000行模型类。 ..只是以1串添加到的ListView

They tell you that you need just one line to activate it, but you will find it's a headache and a lot more work then it's worth. I highly suggest you to stick to the normal ListView, otherwise you will find yourself writing a 1000 lines model class... Just to add 1 string to a ListView.

只是这个道理 ObjectListView 业务,你看起来太成前...

Just the truth about this ObjectListView business before you look too much into it...

去下载例子,看一看,我觉得很容易,只需使用普通的的ListView 坦率地说。

Go download the example and take a look, I find it easier to just use a normal ListView frankly.

这篇关于ObjectListView投异常(点击测试)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆