|
-
May 11th, 2013, 09:45 AM
#1
Thread Starter
Hyperactive Member
listview - count checked items
Hope someone can help..........
Code:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
For Each CheckedApp As ListViewItem In App_List.Items
CheckedApp.Checked = True
Button1.Text = "Start installing (" + App_List.Items.Count > -1 + " apps.)"
Next
ElseIf CheckBox1.Checked = False Then
For Each CheckedItem As ListViewItem In App_List.Items
CheckedItem.Checked = False
Next
End If
End Sub
problem, checkbox1 isn't checking items and the button text, i not sure works....
-
May 11th, 2013, 09:59 AM
#2
Re: listview - count checked items
Your question (and I use the term loosely) doesn't really make sense. The title mentions counting checked items but your code doesn't seem to have anything to do with counting. I'm guessing that English is not your first language but please try to provide a FULL and CLEAR explanation of what you're actually trying to achieve instead of expecting us to work it out from code that doesn't actually work.
-
May 11th, 2013, 10:48 AM
#3
Re: listview - count checked items
I don't understand the question either...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 11th, 2013, 10:53 AM
#4
Re: listview - count checked items
Code:
Button1.Text = "Start installing (" + App_List.Items.Count > -1 + " apps.)"
Shouldn't that be
Code:
Button1.Text = "Start installing (" + (App_List.Items.Count - 1).ToString() + " apps.)"
?
Other than that, I can't really guess what's wrong.
-
May 11th, 2013, 11:15 AM
#5
Re: listview - count checked items
formlesstree4 is right, but also you're resetting Button1.Text for every item in your loop. in vb2012:
Code:
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
Array.ForEach(App_List.Items.Cast(Of ListViewItem).ToArray, Sub(lvi) lvi.Checked = CheckBox1.Checked)
Button1.Text = If(CheckBox1.Checked, "Start installing (" + (App_List.Items.Count > -1).ToString + " apps.)", "some other string")
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 11th, 2013, 11:23 AM
#6
Thread Starter
Hyperactive Member
Re: listview - count checked items
Checkbox1 should check allitems in listtview but is not...
and am not sure if the button text that counts, works..
-
May 11th, 2013, 11:26 AM
#7
Re: listview - count checked items
try my code from post #5
I tested it + I know it works, as does your original code with formlesstree4's modification
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 11th, 2013, 11:50 AM
#8
Thread Starter
Hyperactive Member
Re: listview - count checked items
I got error: Error 1 'Cast' is not a member of 'System.Windows.Forms.ListView.ListViewItemCollection'. H:\X17-59183\PostInstall\PostInstall\SelectPrograms.vb 40 23 PostInstall
plus what exactly does the code do?
-
May 11th, 2013, 12:29 PM
#9
Re: listview - count checked items
It checks or unchecks all items + sets the button text.
Which version of vb are you using + which framework are you targetting?
Last edited by .paul.; May 11th, 2013 at 12:39 PM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
|