Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Private Sub ListViewPlus_ItemChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListViewPlus1.ItemChangedīutton1.Enabled = > 0 Like I said I wrote this because I was bored.
VB NET 2010 LISTVIEW FIND ITEM KEYPRESS CODE
Put your code for enabling and disabling the button in the ItemChange Event. Drag it to the form and it will be identical to the listview except you will have an additional ItemChanged event. Rebuild the solution and the control will be in the toolbox. The Custom ListViewItem Collection will raise an Event whenever items change.Īll you have to do is create a class named ListViewPlus and copy and paste the code into it. It shadows the Items Property to return the custom ListViewItemCollection. Theres really nothing special about the following. I do have a ListViewPlus like the class below that has ItemMouseClick, Radio and Checkboxes, and more. But If you start making custom controls and keep adding to them then the future will allow you to drag and drop with all kinds of additional functionality. This will look like overkill and it is if your only going to use it one time.
You can however create your own listview with an ItemChanged event. You can just check the list views items count whenever you make a change and disable or enable the button. Not sure if there is a binding for the items count.