newbie: how to use the CheckListBox

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
 
B

bz

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!>
 
M

mnadeem.abbasi

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
 
B

bz

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.
 
M

mnadeem.abbasi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top