|
-
Oct 30th, 2000, 08:28 AM
#1
Thread Starter
Hyperactive Member
Hi,
I have a form with a ListBox (with Style = 1-Checkbox) and a command button. At any time the listbox contains between 5 and 15 itmes that user can check (select). I want the command button to be enabled ONLY if 1 or more items in the listbox are CHECKED (not just highlighted). And as soon as user deselects ALL items I want to disable the command button.
Your help is appreciated.
-
Oct 30th, 2000, 08:47 AM
#2
transcendental analytic
Try this:
Code:
Private Sub List1_ItemCheck(Item As Integer)
static selcount As Integer
selcount = selcount - (List1.Selected(Item)) * 2 - 1
Command1.Enabled = selcount
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 30th, 2000, 09:55 AM
#3
Thread Starter
Hyperactive Member
Thanks Kedaman, It works great!
Can you explain how it works, I'm puzzled by the code.
Specially those two lines:
selcount = selcount - (List1.Selected(Item)) * 2 - 1
Command1.Enabled = selcount
-
Oct 30th, 2000, 11:44 AM
#4
transcendental analytic
The selected property returns true if the item specified by index, is selected. And of course false if not.
Well in vb
false = 0 and
true = -1
The selcount i declared static there should count the amount of items selected, if the item that was clicked is set false then you need to decrease selcount, on the other hand true should increase selcount. To get -1 and +1 instead of 0 and -1 you multiply by 2 and substract 1.
Enable is a boolean property and should be set to true if selcount is non-0 that means the implicit convertion used is cbool().
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|