禁用复选框选择在VB .NET 2008 Winform的列表视图 [英] Disabling checkbox selections in VB .NET 2008 Winform Listview
问题描述
你如何禁用其他复选框选项/ deselections不牺牲ListView控件的功能?我知道你可以拨打:ListView.Enabled =假,但也禁用其中的任何滚动
How do you disable additional checkbox selections/deselections without sacrificing the functionality of the ListView? I know you can call: ListView.Enabled = False, but that also disables any scrolling within it.
例如:我有一个启动的基础上被选中的列表视图项的备份计时器。过了一段时间,我不想让最终用户能够在列表视图中点击任何复选框(所以我有项目的备份集数),但我希望他们能够滚动而正在执行列表中的备份。我想这样的:
For example: I have a timer that starts a backup based on the Listview items that are checked. After a certain time, I don't want the end-user to be able to click on any of the checkboxes within the listview (so I have a set number of items to backup), but I do want them to be able to scroll the list while the backup is being performed. I tried this:
Private Sub clboxOptions_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles clboxOptions.ItemChecked
If backupStarted = True Then
If e.Item.Checked = True Then
e.Item.Checked = False
Else
e.Item.Checked = True
End If
不过,这似乎并没有为我工作。 谢谢! JFV
But this doesn't seem to work for me. Thanks! JFV
推荐答案
我发现了什么我的问题是。我用的是ItemChecked的而不是ItemCheck的方法。下面code对我的作品:
I found out what my issue was. I was using the 'ItemChecked' instead of the 'ItemCheck' Method. The below code works for me:
Private Sub clboxOptions_ItemCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles clboxOptions.ItemCheck
Try
If backupStarted = True Then
If e.CurrentValue <> e.NewValue Then
e.NewValue = e.CurrentValue
Else
e.NewValue = e.NewValue
End If
End If
End Sub
这篇关于禁用复选框选择在VB .NET 2008 Winform的列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!