newbie: how to use the CheckListBox

  • Thread starter Thread starter bz
  • Start date Start date
B

bz

Hi,

I fill out a CheckListBox from the IDE with 10 items.
I am trying to mark the checkboxes in a CheckListBox at runtime. But... I
have absolutely no idea how to do that.

(e.g.) I want to mark the 5th and the 6th items at Form_Load.

<g> be using VB6 for 10 years and have no idea what to do!!! Ahhhhahahaaa!

I press F1 but the example has absolutely no explanation whatsoever. (I am
sure I will understand how to do that after I go over the entire class
structure...)

Help please!

Thanks!

--
There is no answer.
There has not been an answer.
There will not be an answer.
That IS the answer!
And I am screwed.
Deadline was due yesterday.

There is no point to life.
THAT IS THE POINT.
And we are screwed.
We will run out of oil soon.

http://spaces.msn.com/bzDaCat
 
Ok... I am looking through the class diagram...
There is an ObjectCollection class.
Aha! And then there is the example to mark the checkbox in the CheckListBox
class...

To mark the check box, use the:

SetItemCheckState(i, State) method

<G!>
 
just use

With CheckedListBox1
.Items.Add("1")
.Items.Add("11")
.Items.Add("111")
.Items.Add("1111")
.Items.Add("11111")
.Items.Add("111111")

.SetItemChecked(4, True)
.SetItemChecked(5, True)
End With
 
Hi,

Thanks.

now I am trying figure it out how to get the index of the checked item.
(just why they want to make this so difficult!!!)

I can get the checked item object (CheckedItems) but I can't seem to be able
to get their index in the CheckedListBox.
 
With CheckedListBox1
.Items.Add("1")
.Items.Add("11")
.Items.Add("111")
.Items.Add("1111")
.Items.Add("11111")
.Items.Add("111111")

.SetItemChecked(4, True)
.SetItemChecked(5, True)
End With
Dim i As Int16

' GETTING CHECKED ITEM INDEX
For i = 0 To CheckedListBox1.Items.Count - 1
If CheckedListBox1.GetItemChecked(i) = True Then
MsgBox("Value: " & CheckedListBox1.Items(i).ToString,
MsgBoxStyle.Information, "List Index: " & i.ToString)
End If
Next
 
Back
Top