列表查看计数事件? [英] list view count event?

查看:51
本文介绍了列表查看计数事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索要使用的事件,同时在标签中显示列表视图中的项目总数。标签还可以,但我已经尝试了一系列事件。非工作。是否有任何建议的方法?

I have been searching for an event to use while displaying in a label the total count of items in my listview. The label is ok but i've tried a list of events. non are working. Are there any suggested methods?

推荐答案

没有从ListView添加/删除项目的事件。但是你可以做些什么...



您可以创建一个新的ListView控件,从ListView派生,并为AddItem和RemoveItem添加一个方法。在这些方法中,您将项目添加/删除到项目列表,并为ItemsChanged或类似的东西举起您自己的事件。



我道歉我不能发布代码来做到这一点,我不是很擅长VB。希望其他人可以给你一个有效的例子,它不需要太多代码就可以了。
There is no event for an item being added/removed from a ListView. But there is something you can do about it...

You can create a new ListView control, deriving from ListView, and add a method to it for AddItem and RemoveItem. In these methods, you add/remove the item to the Items list, and raise your own event for an ItemsChanged or something similiar.

I apologize that I can't post code to do this, I'm not very good in VB. Hopefully somebody else can give you a working example, it doesn't take much code to do it.


从工具箱创建一个计时器并将间隔设置为1000

在timer1的tick_event下

只需编写此代码

create a timer from toolbox and set interval to 1000
under the tick_event of the timer1
just write this code
Static x As Integer = 0
        If ListView1.Items.Count > x Then
            x += Val(ListView1.Items.Count - x)
        ElseIf ListView1.Items.Count < x Then
            x -= Val(x - ListView1.Items.Count)
        End If
        Label1.Text = x





请制作如果它能帮助你,请确保将此标记为已解决....快乐编码



please make sure you flag this as solved if it helped you....happy coding


这篇关于列表查看计数事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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