Listview检查项目事件的问题 [英] Problem with listview check item event

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

问题描述

我已经创建了一个带有复选框的列表视图的小型应用程序.每次检查项目时,我都需要执行一个函数.我使用了检查项目事件,当我单击项目的复选框时,它会在检查项目并将其放入列表视图的选中项目集合之前触发检查项目事件,它的作用就像单击事件.当我取消选中该项目时,它将触发检查项目事件,但是到那时,它将把单击的项目添加到列表视图的选中项目列表中,但是在界面上该项目未被选中.怎么回事?
请帮忙!!!!

I''ve created a small application to with a list view with checkboxes. I need to execute a function everytime an item is checked. I used the check item event and when I click the check box of the Item it fires up the check item event before the item is checked and put into the checked items collection in the list view, it simply acts like the click event. When I uncheck the item it will fire up the check item event but that time it will add the clicked item into the list view''s checked items list but on the interface the item is unchecked. What''s going on?
Please help!!!!

推荐答案

我认为您是指Windows窗体CheckedListBox控件-在您的查询中要更具体

使用ItemCheck事件.参数"e"将具有所有必需的信息,例如商品编号,当前值和单击时的先前值.
这是事件处理程序的示例


I think you''re referring to the Windows Forms CheckedListBox control - be more specific in your queries

Use the ItemCheck event. the argument ''e'' will have all the required info like the item number, current value & previous value when clicked.
Here''s an example event handler


Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
    MsgBox("Check change on row : " & e.Index & vbNewLine & _
           "Current State : " & e.CurrentValue.ToString() & vbNewLine & _
           "New State after click : " & e.NewValue.ToString())
End Sub


这篇关于Listview检查项目事件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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