天道酬勤,学无止境

objectlistview

如何使用 ObjectListView 对列中的文本进行自动换行(How to wordWrap the text in a column using ObjectListView)

问题 例如我有一个大句子: “我喜欢吃馅饼,整天在家里玩得很开心!” 我希望它看起来像这样: “我喜欢吃馅饼,整天在家里玩得很开心!” 在这篇文章中:WinForms ListView 控件上的多行列表项? Grammarian 说你只需要打开 WordWrap 但我找不到那个选项。 感谢您的高级帮助 回答1 每列都有一个WordWrap属性。 将其设置为true ,该列的文本将换行。 请记住,列表必须是 OwnerDrawn 才能使包装可见。 编辑:我今天又看了一遍,你说得对——那处房产不见了! 我不知道它已经消失到哪里去了。 我确定它曾经在那里:( OLVColumn应该有这样的属性: [Category("Behavior - ObjectListView"), Description("Draw this column cell's word wrapped"), DefaultValue(false)] public bool WordWrap { get { return wordWrap; } set { wordWrap = value; if (wordWrap) { this.Renderer = new BaseRenderer(); ((BaseRenderer)this.Renderer).CanWrap = true; ((BaseRenderer

2021-06-12 17:00:48    分类:技术分享    c#   .net   listview   objectlistview

如何在虚拟模式下将项目添加/删除到ListView?(How do I add/remove items to a ListView in virtual mode?)

问题 如果我在虚拟模式下使用ListView,那么据我所知,列表视图仅跟踪列表中的少量项目。 当用户滚动时,它会动态检索需要从虚拟列表中显示的项目。 但是,如果在主列表中添加或删除了项目,该怎么办? 如果在列表视图显示的索引范围之外添加/删除项目,则我认为当用户滚动到该索引时,列表视图将显示添加/缺失的项目。 这样对吗? 但是,如果从用户当前正在查看的索引范围中添加/删除项目,该怎么办? 如何触发列表视图以刷新其当前正在查看的项目以显示新项目/缺失项目? 仅供参考:如果有任何区别,我正在使用ObjectListView。 回答1 虚拟列表对您的项目列表一无所知。 它不会跟踪它们,甚至也不是一小部分。 它只会问“您想在第n行显示什么?”。 如果主列表发生更改,那么您只需要做的就是重新绘制列表。 Invalidate()将为您做到这一点。 然后,列表视图将再次询问您在控件中可见的每一行应显示什么。 如果您使用的是ObjectListView,是否考虑过使用FastObjectListView,它可以为您提供虚拟列表的快速好处,并且易于使用普通的ObjectListView?

2021-05-31 15:13:50    分类:技术分享    c#   .net   winforms   listview   objectlistview

ObjectListView强制转换异常(用于命中测试)(ObjectListView cast exception (for hit testing))

问题 我正在使用Grammarian的ObjectListView。 我将原来的列表视图更改为该列表视图,但是我要做的就是填写项目。 但是,当应用程序启动并且我的鼠标位于列表视图上方时,它立即引发以下异常: System.InvalidCastException was unhandled Message="Unable to cast object of type 'System.Windows.Forms.ListViewItem' to type 'BrightIdeasSoftware.OLVListItem'." Source="ObjectListView" 如何解决这个问题? 如果重要的话,我也使用Win7。 编辑: 我用字典。 看来我需要使用SetObjects方法而不是添加项目。 好的,这很好,但是我只是在使用dict.Value集合。 我不想通过listview修改数据,仅显示。 因此,我只有1列,并列出其中的所有字符串。 这可能吗? 我将不胜感激。 回答1 没错-您应该使用SetObjects()方法,而不是添加ListViewItems 。 在ObjectListView中,永远不应有ListViewItems. 该控件跟踪更多信息,因此需要的内容比ListViewItems所提供的更多。 您可能需要阅读网站的“入门”页面,尤其是“必须取消学习”部分。

2021-05-18 10:42:03    分类:技术分享    c#   .net   vb.net   winforms   objectlistview

ObjectListView显示图标(ObjectListView show icons)

问题 试图在ObjectListview中放置图标,这是我应该在其中放置图标的代码: objectListView1.SmallImageList = imageList1; deleteColumn.IsEditable = true; deleteColumn.ImageGetter = delegate { return 0; }; deleteColumn.AspectGetter = delegate { return "Delete"; }; imageList1已经有一个图像,此代码应该在“删除”旁边放置一个图标,但是它完全没有出现,通过食谱和Google进行查看,我仍然不知道。 谁能帮我? 如果需要,这是完整的表单代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Security.Cryptography; using System.IO; namespace WindowsFormsApplication1 {

2021-05-18 07:41:42    分类:技术分享    c#   icons   objectlistview

ObjectListView cast exception (for hit testing)

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

2021-05-08 03:24:49    分类:问答    c#   .net   vb.net   winforms   objectlistview

Objectlistview how to change the text in the group header?

I want to change the name of the group header but i cant find any solutions in the documentation or on google. the text in the header should be a time which is summed up in the group. this is how it should look like:

2021-05-01 23:58:17    分类:问答    c#   listview   sum   objectlistview

ObjectListView show icons

Trying to put icons in ObjectListview, here's my piece of code where icon should have been put: objectListView1.SmallImageList = imageList1; deleteColumn.IsEditable = true; deleteColumn.ImageGetter = delegate { return 0; }; deleteColumn.AspectGetter = delegate { return "Delete"; }; imageList1 already have an image, this code should have put an icon next to "Delete", but it did not appear at all, looked through cookbooks and Google and I still have no idea. Can anyone help me? this is the full form code in case needed: using System; using System.Collections.Generic; using System.ComponentModel

2021-04-30 07:31:59    分类:问答    c#   icons   objectlistview

How do I add/remove items to a ListView in virtual mode?

If I'm using a ListView in virtual mode then, as I understand it, the list view only keeps track of a small number of items in the list. As the user scrolls it dynamically retrieves items it needs to show from the virtual list. But what if an item is added or removed from the master list? If an item is added/removed outside of the range of indexes being shown by the list view then I would assume the list view would show the added/missing items when the user scrolls to that index. Is this correct? But what if an item is added/removed from the range of indexes the user is currently viewing? How

2021-04-29 11:43:44    分类:问答    c#   .net   winforms   listview   objectlistview

How to wordWrap the text in a column using ObjectListView

For example I have a big sentence: "I like to eat pie and have fun around the house all day long!" And I want it to appear like this: "I like to eat pie and have fun around the house all day long!" In this post: Multi-line list items on WinForms ListView control? Grammarian said that you only need to have WordWrap on but I cannot find that option. Thanks for the help in advanced

2021-04-21 07:57:54    分类:问答    c#   .net   listview   objectlistview

How to add a new item into ObjectListView?

I tried the demo code in demo project but I can't add new item successfully. It just add new new NULL group and NULL item. Please give me an simple example code to add new item (text and image). Thank you! Oh sorry! I forgot it. This is the first time I participate in this site. I use C#. And the code is: objectListView1.BeginUpdate(); objectListView1.AddObject(new string [] {"Hello","dfdsF" }); objectListView1.EndUpdate(); and objectListView1.BeginUpdate(); OLVListItem item = new OLVListItem(new string [] {"Hello","dfdsF" }); objectListView1.Items.Add(item); objectListView1.EndUpdate(); It's

2021-04-20 16:44:03    分类:问答    objectlistview