checked list controls in VB????

Status
Not open for further replies.
k, what i suppose i was trying to say...pls xcuse me its been an awful couple of days....

what i am trying to do....

i have a startup form than spawns approx 20 or so other forms....

each of these baby forms (?) has a list of options ...some have over a hundred and some have only one or two....

i fugured the best way to to save on zillions of check boxes was to use the list property style check box as you suggested...

but my problem really lies in the fact that i want the user to be able to select multiples from the list....

i eventually worked out (you can tell i'm new to this game can't you) that the only way to have multiple selections was to use the MultiSelect property (which cant be used on the checked.list style ) (back over all the baby forms to change back to basic list style)...

what i would desperately like to know is how do i get vb to recognise what has been selected from the list (of poss over 100 items) without doing a hundred or so SelectCase .... Case 0, case 1 commands....

and further more....


who on gods green earth thought it was clever to not allow an option button command to not be deselected....

i did have the idea of using an option (radio) button as a select all...which would set to false if 1 or two items were selected...


should i rephrase nay of this as 1...i am probably not making musch sense thru fatigue ....(too many vb manuals in a week can do this ...)

please someone help.... :confused:
 

HL7

Ars Praefectus
3,523
Subscriptor++
Use a ListView instead of a ListBox.

Project ... Components ... Microsoft Common Controls

Then add a ListView. You can set Checkboxes and Multiselect. Works perfectly.

who on gods green earth thought it was clever to not allow an option button command to not be deselected....
You could create an OnClick event for the option button to deselect it if it's already selected. e.g. in the OnClick event, say "If optWhatever.Value Then optWhatever.Value = False"

what i would desperately like to know is how do i get vb to recognise what has been selected from the list (of poss over 100 items) without doing a hundred or so SelectCase .... Case 0, case 1 commands....
If you use a ListView, then you can do this:

code:<HR>
Code:
Dim l as ListItem

For Each l in lvwMyListView.ListItems
  If l.Checked Then
    ......
  End If
Next
Substitute l.Selected if you're using MultiSelect instead of Checkboxes.

[This message was edited by HL7 on February 25, 2002 at 22:32.]
 
What am i doing wrong....i was told

You must dim itmX as ListItem
Set itmx = Listview.Additem
Then Itmx.listSubitems.(index) =

so i have done...
Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)

Dim itmX As ListItem
Set itmX = ListView.AddItem
itmX.ListSubItems.Add(1) = a
itmX.ListSubItems.Add(2) = b
itmX.ListSubItems.Add(3) = c
itmX.ListSubItems.Add(4) = d
itmX.ListSubItems.Add(5) = e
itmX.ListSubItems.Add(6) = f


End Sub

but i am getting a blank listview box...
:(
 
I am going mad....

i have been to :

http://www.bulletsoftsolutions.com/vb/
http://vbcity.com/forums/topic.asp?tid=1853
http://www.mvps.org/vbnet/index.html?code/comctl/lvdemo2.htm
http://www.pscode.com/vb/default.asp?lngWId=1
http://www.vbinformation.com/tutor.htm

in addition i have been reading :

MS VB step by step
Computer programming concepts and VB (david I. schneider)

and whilst i admit..i am totally new to this game and could do with being alot more thorough in my approach to all these sources...

i am struggling at each and every step of the way...

please can sum1 any one (i afraid HL7 seems to be bearing the burden of my incompetance) tell me how to use a listview in its simplest form without class modules and all the other high brow stuff...

dont get me wrong...i admire the elegance of the code...but i am as yet unable to utilise it....

keep getting error msgs..from the above code even tho ihave moved it to the Private Sub form load ()

i have tinkered with it for hours now...and am increasingly close to :
a) tears
b) my deadline
c) being humiliated by my line manager

please can sum1 help me salvage this project and i will gladly offer you my soul for all eternity..(its in quite good condition)

there is no little icon for a guy pulling his hair out...

=`, :(
 

HL7

Ars Praefectus
3,523
Subscriptor++
Here's code to fill a ListView. This sets everything up so all you have to do is create a form, drop a listview on it, paste this code into Form_Load, and it'll go.

code:<HR>
Code:
Private Sub Form_Load()
    Dim NewItem As ListItem
    Dim i As Integer
    
    ListView1.ListItems.Clear
    ListView1.View = lvwReport
    ListView1.MultiSelect = True
    ListView1.Checkboxes = True
    
    ListView1.ColumnHeaders.Add , , "i"
    ListView1.ColumnHeaders.Add , , "i+1"
    
    For i = 1 To 10
        Set NewItem = ListView1.ListItems.Add(, "i" & Trim(Str(i)), Str(i))
        NewItem.SubItems(1) = Str(i + 1)
    Next
End Sub
 
i wouldnt wouldn't want to play your code against jj's

but i do prefer your code ...

is there a method where i can use a dim statement to automatically populate the list...

i remember when i was a lad...i used to use

dim A$
data A$ a,b,c,d,e,f
...
...
print a$...
...
read a$

and that would use a$ each field in turn in a later bit of code


cheers for your help again
 
in the mean time today i learnt how to make the best use of an array...

for the unavoidable 90 odd checkboxes on the startup...(just thought i'd let u know how i've been getting on (with 11hrs 2 go does anyone fancy running a book :) )

...

is there a similar command to ...

ListView1.View = lvwReport

to achieve a header auto size....


i saw what i thougth was one..but is was tied to a class and a module and seemed to be returning something somewher...but i cudn't make head nor tail of it to be honest...
 
Status
Not open for further replies.