Can ListView have checkboxes?

companyHM
02-12-2008, 06:23 AM
In an effort to transition from a VBA macro to a VB6 Add-In, I'm switching from a ListBox to a ListView. In the macro, I'm using a ListBox with certain properties set such as ColumnCount=3, ListStyle=1-frmListStyleOption, and ColumnWidths, to populate a ListBox and allow the user to select certain rows for an action.

I found in VB6 that things are a little different. After running across the ListView control, I figured this was the way to go. However, I haven't figured out the whole check box thing (besides highlighting) with MultiSelect=True and View=3-lvwReport. Does anyone know what I'm talking about and have any insight into this? Thanks!

I've also have some useful links:
Xtreme VB Talk: Want Listview acting like Listbox (http://www.xtremevbtalk.com/showthread.php?t=278616)
Xtreme VB Talk: From ListBox 2 ListView (http://www.xtremevbtalk.com/showthread.php?t=278818)
ListView Control - Introduction (http://www.developerfusion.co.uk/show/74/1/)
MSDN: Listview Control (http://msdn2.microsoft.com/en-us/library/3bz1s4ky.aspx)

the master
02-12-2008, 06:47 AM
Um. What exactly is the question? You can add checkboxes by setting .checkboxes=true. Is that what you meant?

companyHM
02-12-2008, 07:06 AM
The ListView class doesn't have a Checkboxes member though does it?

Hmm, the question is how can I get what I was doing in VBA to work in VB6. I populated a (VBA!)ListBox with items and allowed the user to select the items they wanted to perform the task on, via the property ListStyle = 1-frmListStyleOption. The program would step down through the ListBox and perform the task on the checked items and then uncheck each and continue on.

It seems like you could do things a similar way with ListView by dragging and highlighting and Cntl+Click adding more. But it doesn't seem as user friendly. So that's the reason for the thread title, can a ListView have checkboxes? Or maybe there's a better solution that I don't know about.

the master
02-12-2008, 07:12 AM
I might have missed something here. I have a listview on a form which has checkboxes on it. Im using VB6 too

the master
02-12-2008, 07:14 AM
Ive just noticed something. The listview control in "Microsoft Windows common controls 5.0" does not have a checkboxes option. I assume you were using that? I was using the one from "Microsoft Windows common controls 6.0" which does have the option

companyHM
02-12-2008, 07:24 AM
Man, how did you know that? Correct, I was using 5.0. That's exactly what I was looking for, although it does seem like it works a little different than the ListBox in VBA I'm used to. Thank you so much!

Is there an easy way (without too much code maybe) to allow multiple selection of boxes? I'll probably add a "select all" checkbox but for wanting to select a group, what can you do? Almost like getting the MulitSelect property to check the checkboxes.

the master
02-12-2008, 08:26 AM
Man, how did you know that?

Simple really. V5 doesnt have the property. V6 does have it. You didnt have it so you must have been using V5.


Is there an easy way (without too much code maybe) to allow multiple selection of boxes? I'll probably add a "select all" checkbox but for wanting to select a group, what can you do? Almost like getting the MulitSelect property to check the checkboxes.

I dont think theres a built in method to do this but a simple loop should do. Loop through all the items and set .checked=true on each one (or false if you want)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum