Checkbox in listview 
Author Message
 Checkbox in listview

If I set the listview control to have checkboxes, using LVS_EX_CHECKBOXES,
how do I check one of the items in code?  I have the code to retrieve if an
item is checked, but I would like to know how to make an item checked from
code?

Thanks.

-Dave



Sat, 09 Sep 2000 03:00:00 GMT  
 Checkbox in listview

http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm

Quote:

>If I set the listview control to have checkboxes, using LVS_EX_CHECKBOXES,
>how do I check one of the items in code?  I have the code to retrieve if an
>item is checked, but I would like to know how to make an item checked from
>code?

>Thanks.

>-Dave




Sat, 09 Sep 2000 03:00:00 GMT  
 Checkbox in listview

    I think this may be what you're looking for.  I'm using VB5.0 and have
been working on a project, part of which uses a listbox control with
checkboxes enabled.  I set and clear these boxes through code.  As you
doubtless know, each row in a listbox has an index number automatically
assigned to it.
    Regardless of whether checkboxes are enabled for the listbox or not, the
method of programmatically selecting and deselecting the items (or rows) in
the listbox is the same--all you need do is specify the index number of the
item (or row) you want to select, and set the "selected" property to TRUE.
For example, let us assume your listbox is called "list1".
    If you know which specific item you want to select, specify it's index
number in a statement like this:

    list1.selected(5) = true

This would select (in the case of a listbox with checkboxes enabled, it
would "check") the fifth item in the list.  If you don't know (or care)
about the specific index numbers of the items you want to check, you could
use an iterative construct.  For example, I used the following in my own
code just today:

for i = 0 to list1.SelCount - 1     ' check each entry in the listbox
    if list1.selected(i) = TRUE then list1.selected(i) = FALSE
next i

As you can see, all this does is race through the list, UN-checking every
item that the user checked.  To make the code CHECK every item, you would
simply reverse the TRUE and FALSE values.  Hope this helps.  E-mail me and
let me know how it works for you.


Quote:

>If I set the listview control to have checkboxes, using LVS_EX_CHECKBOXES,
>how do I check one of the items in code?  I have the code to retrieve if an
>item is checked, but I would like to know how to make an item checked from
>code?

>Thanks.

>-Dave




Sat, 09 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Checkbox in ListView

2. Three state checkbox in listview

3. Greyish checkboxes in ListView

4. read-only checkboxes for listview

5. Checkbox in listview

6. Checkboxes in listview

7. Programmatically set checkboxes in ListView???

8. Checkboxes in Listview?

9. Checkboxes in ListView control

10. checkbox in ListView

11. Checkbox in listview

12. Checkbox in listview

 

 
Powered by phpBB® Forum Software