|
-
Jul 2nd, 2012, 04:04 PM
#1
Thread Starter
Hyperactive Member
How to check the checkboxes in the listview?
Hi guys,
I am working on my listview which I have almost finish it, but i need to work on the button event to check for each string in the listview whether if the checkbox is true or false. When I tick and untick on the checkboxes to add the strings in the label, I want to know how i can check them out through on the listview to see if the checkbox is true or false?
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 if the checkboxes in the listview compare to each string that I add in the label is true or false?
Can anyone help me with this?
-
Jul 2nd, 2012, 04:16 PM
#2
Addicted Member
Re: How to check the checkboxes in the listview?
I have absolutely no idea what you are asking.
Can you break down the steps of your program using:
1.
2.
3.
4.
And then tell us what part of that sequence you are having trouble with.
Right now, the best I can gather is:
1. The program loads up
2. You add items to a listbox
3. You can check or uncheck items in the listbox
4. You click a button
5. If the item is unchecked it is deleted?
6. A message box appears with what items are checked.
I have no idea where the label fits in, so be more descriptive when you write out the steps
-
Jul 2nd, 2012, 05:21 PM
#3
Thread Starter
Hyperactive Member
Re: How to check the checkboxes in the listview?
Ok, here is a break down of a step of what I want to do:
1. The program loads up
2. I add the items to a listview
3. I tick and untick the items in the listview to add each strings in the label like mystrings 1, mystrings 2
4. I click a button to split the strings in the label and check each strings from the label to the listview to see if each strings in the listview have checked and unchecked checkboxes
5. A message box appears with each items if the checkboxes are checked or unchecked.
Hope it will make sense of what i am trying to do.
-
Jul 2nd, 2012, 05:44 PM
#4
Re: How to check the checkboxes in the listview?
If you are adding Strings from clicking checks in the ListView, then its not necessary to go over the list in the Label to match them to a ListView item since it was the ListView that created them in the first place. That's really not efficient. Why would you want to do that anyway ?
-
Jul 2nd, 2012, 06:04 PM
#5
Re: How to check the checkboxes in the listview?
 Originally Posted by PillKilla
3. I tick and untick the items in the listview to add each strings in the label like mystrings 1, mystrings 2

#3 - So the listview string item is added to a label when you tick a checkbox and also when you untick a checkbox?
BTW you asked this same question a couple days ago here, whats changed? Why not reply to that thread?
-
Jul 2nd, 2012, 06:37 PM
#6
Thread Starter
Hyperactive Member
Re: How to check the checkboxes in the listview?
 Originally Posted by Edgemeal

#3 - So the listview string item is added to a label when you tick a checkbox and also when you untick a checkbox?
BTW you asked this same question a couple days ago here, whats changed? Why not reply to that thread?
Yes, when i tick and untick a checkbox, it will add the string item to a label.
So now I am working on the button event to compare the string item from a label and the listview as i want to check if the listview items is true or false. Can you please help me with that?
As for my previous thread, nobody is answers so i think i would start a new one and explains a bit better.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|