Hi guys,
I am working on my listview as I have almost finish it, but there is a problem with the checkboxes. When I run my form on a debug, I have the first row are already set to true and when click on the second row in the listview to set the checkbox to true while it will add the subitems in the label, so when I click on a button, it will say that the first row have set to true which I have only select on a second row in the listview.
Here's the code:
Code:Private Function GetEnabledDisabledText(ByVal enabled As Boolean) As String Return (If(enabled, "Enabled", "Disabled")) End Function Private Shared subItems1 As New List(Of String)() Private Sub listView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim strItem As String = listView1.HitTest(e.Location).Item.SubItems(1).Text If subItems1.Contains(strItem) Then subItems1.Remove(strItem) Else subItems1.Add(listView1.HitTest(e.Location).Item.SubItems(1).Text) End If label3.Text = String.Join(", ", subItems1.ToArray()) End Sub Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) button1.Enabled = False Dim a() As String = Nothing a = label3.Text.Split(","c) Dim j As Integer = 0 Dim str As Object = GetEnabledDisabledText(listView1.Items(j).Checked) MessageBox.Show(a(j).Trim() & " is " & str.ToString()) End Sub
Do you know how I can get the messagebox to display and tells me which rows in the listview that I have select and whether if the checbox is set to true or false after I add the subitems in the label?
Can anyone help me with this?




Reply With Quote