By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

CheckedListBox Question

P: n/a
Here is some code that I need help with please:

Dim result As New ArrayList
Try
For i = 0 To objecttest1.PersonList.person_returnnumber - 1
result =
objecttest1.PersonList.time_returnpunches(objectte st1.PersonList.person_getb
yid(i).userid, "03/08/2004", "03/09/2004", True, False)
'The above line returns an object with several proerties, namely, a
punch id that I want to be able to get out of the checkedlistbox collection:
For j = 0 To result.Count - 1
If result(j).approval = True Then
CheckedListBox1.Items.Add(result(j).ToString, True)
Else
CheckedListBox1.Items.Add(result(j).ToString, False)
End If
Next
Next
....
End Try

Okay so far...now, I want to find out which object ID's in the
checkedlistbox collection have what state:

Dim item As Object
Dim quote As String = """"
For Each item In CheckedListBox1.Items
MessageBox.Show("Item with id: " + item.GetType.ToString + _ 'Problem
is on this line
" is: " +
CheckedListBox1.GetItemCheckState(CheckedListBox1. Items.IndexOf(item)).ToStr
ing() + ".")
Next

The segment item.GetType.ToString returns System.String which is confusing
me because I think it means that the objects in the checkedlistbox
collection are string objects and not the objects themselves, which would
explain why I can't reference a member of the punch object (id). Is this
correct?

If it is, how can I do this so that I get the object's time property for
each indexed collection? For example, I am wanting:

checkedlistbox1 index = 0 results in this messagebox: Item with ID: 932 is:
unchecked
where '932' is the ID property of the time object that was loaded into the
checkedlistbox

Thanks so much!

Derek
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Here is some code that I need help with please:

Dim result As New ArrayList
Try
For i = 0 To objecttest1.PersonList.person_returnnumber - 1
result =
objecttest1.PersonList.time_returnpunches(objectte st1.PersonList.person_getb yid(i).userid, "03/08/2004", "03/09/2004", True, False)
'The above line returns an object with several proerties,
namely, a
punch id that I want to be able to get out of the checkedlistbox
collection:
For j = 0 To result.Count - 1
If result(j).approval = True Then
CheckedListBox1.Items.Add(result(j).ToString, True)
Else
CheckedListBox1.Items.Add(result(j).ToString, False)
End If
Next
Next
...
End Try

Okay so far...now, I want to find out which object ID's in the
checkedlistbox collection have what state:

Dim item As Object
Dim quote As String = """"
For Each item In CheckedListBox1.Items
MessageBox.Show("Item with id: " + item.GetType.ToString + _
'Problem
is on this line
" is: " +
CheckedListBox1.GetItemCheckState(CheckedListBox1. Items.IndexOf(item)).ToStr ing() + ".")
Next

The segment item.GetType.ToString returns System.String which is
confusing me because I think it means that the objects in the
checkedlistbox collection are string objects and not the objects
themselves, which would explain why I can't reference a member of the
punch object (id). Is this correct?
Right
If it is, how can I do this so that I get the object's time property
for each indexed collection? For example, I am wanting:

checkedlistbox1 index = 0 results in this messagebox: Item with ID:
932 is: unchecked
where '932' is the ID property of the time object that was loaded
into the checkedlistbox


As you didn't add the objects to the listbox, only a string, there is no
relation to the original object.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Here is some code that I need help with please:

Dim result As New ArrayList
Try
For i = 0 To objecttest1.PersonList.person_returnnumber - 1
result =
objecttest1.PersonList.time_returnpunches(objectte st1.PersonList.person_getb yid(i).userid, "03/08/2004", "03/09/2004", True, False)
'The above line returns an object with several proerties,
namely, a
punch id that I want to be able to get out of the checkedlistbox
collection:
For j = 0 To result.Count - 1
If result(j).approval = True Then
CheckedListBox1.Items.Add(result(j).ToString, True)
Else
CheckedListBox1.Items.Add(result(j).ToString, False)
End If
Next
Next
...
End Try

Okay so far...now, I want to find out which object ID's in the
checkedlistbox collection have what state:

Dim item As Object
Dim quote As String = """"
For Each item In CheckedListBox1.Items
MessageBox.Show("Item with id: " + item.GetType.ToString + _
'Problem
is on this line
" is: " +
CheckedListBox1.GetItemCheckState(CheckedListBox1. Items.IndexOf(item)).ToStr ing() + ".")
Next

The segment item.GetType.ToString returns System.String which is
confusing me because I think it means that the objects in the
checkedlistbox collection are string objects and not the objects
themselves, which would explain why I can't reference a member of the
punch object (id). Is this correct?
Right
If it is, how can I do this so that I get the object's time property
for each indexed collection? For example, I am wanting:

checkedlistbox1 index = 0 results in this messagebox: Item with ID:
932 is: unchecked
where '932' is the ID property of the time object that was loaded
into the checkedlistbox


As you didn't add the objects to the listbox, only a string, there is no
relation to the original object.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

P: n/a
Thanks for teh reply...Okay, so how can I add the object itself to the
checkedlistbox?

Thanks!
Derek

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Here is some code that I need help with please:

Dim result As New ArrayList
Try
For i = 0 To objecttest1.PersonList.person_returnnumber - 1
result =

objecttest1.PersonList.time_returnpunches(objectte st1.PersonList.person_getb
yid(i).userid, "03/08/2004", "03/09/2004", True, False)
'The above line returns an object with several proerties,
namely, a
punch id that I want to be able to get out of the checkedlistbox
collection:
For j = 0 To result.Count - 1
If result(j).approval = True Then
CheckedListBox1.Items.Add(result(j).ToString, True)
Else
CheckedListBox1.Items.Add(result(j).ToString, False)
End If
Next
Next
...
End Try

Okay so far...now, I want to find out which object ID's in the
checkedlistbox collection have what state:

Dim item As Object
Dim quote As String = """"
For Each item In CheckedListBox1.Items
MessageBox.Show("Item with id: " + item.GetType.ToString + _
'Problem
is on this line
" is: " +

CheckedListBox1.GetItemCheckState(CheckedListBox1. Items.IndexOf(item)).ToStr
ing() + ".")
Next

The segment item.GetType.ToString returns System.String which is
confusing me because I think it means that the objects in the
checkedlistbox collection are string objects and not the objects
themselves, which would explain why I can't reference a member of the
punch object (id). Is this correct?


Right
If it is, how can I do this so that I get the object's time property
for each indexed collection? For example, I am wanting:

checkedlistbox1 index = 0 results in this messagebox: Item with ID:
932 is: unchecked
where '932' is the ID property of the time object that was loaded
into the checkedlistbox


As you didn't add the objects to the listbox, only a string, there is no
relation to the original object.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

P: n/a
Thanks for teh reply...Okay, so how can I add the object itself to the
checkedlistbox?

Thanks!
Derek

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Here is some code that I need help with please:

Dim result As New ArrayList
Try
For i = 0 To objecttest1.PersonList.person_returnnumber - 1
result =

objecttest1.PersonList.time_returnpunches(objectte st1.PersonList.person_getb
yid(i).userid, "03/08/2004", "03/09/2004", True, False)
'The above line returns an object with several proerties,
namely, a
punch id that I want to be able to get out of the checkedlistbox
collection:
For j = 0 To result.Count - 1
If result(j).approval = True Then
CheckedListBox1.Items.Add(result(j).ToString, True)
Else
CheckedListBox1.Items.Add(result(j).ToString, False)
End If
Next
Next
...
End Try

Okay so far...now, I want to find out which object ID's in the
checkedlistbox collection have what state:

Dim item As Object
Dim quote As String = """"
For Each item In CheckedListBox1.Items
MessageBox.Show("Item with id: " + item.GetType.ToString + _
'Problem
is on this line
" is: " +

CheckedListBox1.GetItemCheckState(CheckedListBox1. Items.IndexOf(item)).ToStr
ing() + ".")
Next

The segment item.GetType.ToString returns System.String which is
confusing me because I think it means that the objects in the
checkedlistbox collection are string objects and not the objects
themselves, which would explain why I can't reference a member of the
punch object (id). Is this correct?


Right
If it is, how can I do this so that I get the object's time property
for each indexed collection? For example, I am wanting:

checkedlistbox1 index = 0 results in this messagebox: Item with ID:
932 is: unchecked
where '932' is the ID property of the time object that was loaded
into the checkedlistbox


As you didn't add the objects to the listbox, only a string, there is no
relation to the original object.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

P: n/a
Figured it out:
When adding it into the list, force the object itself to be added and
overload the tostring method in the object class.

:-)
Thanks!
Derek
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Thanks for teh reply...Okay, so how can I add the object itself to the
checkedlistbox?

Thanks!
Derek

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Here is some code that I need help with please:

Dim result As New ArrayList
Try
For i = 0 To objecttest1.PersonList.person_returnnumber - 1
result =

objecttest1.PersonList.time_returnpunches(objectte st1.PersonList.person_getb
yid(i).userid, "03/08/2004", "03/09/2004", True, False)
'The above line returns an object with several proerties,
namely, a
punch id that I want to be able to get out of the checkedlistbox
collection:
For j = 0 To result.Count - 1
If result(j).approval = True Then
CheckedListBox1.Items.Add(result(j).ToString, True)
Else
CheckedListBox1.Items.Add(result(j).ToString, False)
End If
Next
Next
...
End Try

Okay so far...now, I want to find out which object ID's in the
checkedlistbox collection have what state:

Dim item As Object
Dim quote As String = """"
For Each item In CheckedListBox1.Items
MessageBox.Show("Item with id: " + item.GetType.ToString + _
'Problem
is on this line
" is: " +

CheckedListBox1.GetItemCheckState(CheckedListBox1. Items.IndexOf(item)).ToStr
ing() + ".")
Next

The segment item.GetType.ToString returns System.String which is
confusing me because I think it means that the objects in the
checkedlistbox collection are string objects and not the objects
themselves, which would explain why I can't reference a member of the
punch object (id). Is this correct?


Right
If it is, how can I do this so that I get the object's time property
for each indexed collection? For example, I am wanting:

checkedlistbox1 index = 0 results in this messagebox: Item with ID:
932 is: unchecked
where '932' is the ID property of the time object that was loaded
into the checkedlistbox


As you didn't add the objects to the listbox, only a string, there is no
relation to the original object.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Nov 20 '05 #6

P: n/a
Figured it out:
When adding it into the list, force the object itself to be added and
overload the tostring method in the object class.

:-)
Thanks!
Derek
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Thanks for teh reply...Okay, so how can I add the object itself to the
checkedlistbox?

Thanks!
Derek

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Here is some code that I need help with please:

Dim result As New ArrayList
Try
For i = 0 To objecttest1.PersonList.person_returnnumber - 1
result =

objecttest1.PersonList.time_returnpunches(objectte st1.PersonList.person_getb
yid(i).userid, "03/08/2004", "03/09/2004", True, False)
'The above line returns an object with several proerties,
namely, a
punch id that I want to be able to get out of the checkedlistbox
collection:
For j = 0 To result.Count - 1
If result(j).approval = True Then
CheckedListBox1.Items.Add(result(j).ToString, True)
Else
CheckedListBox1.Items.Add(result(j).ToString, False)
End If
Next
Next
...
End Try

Okay so far...now, I want to find out which object ID's in the
checkedlistbox collection have what state:

Dim item As Object
Dim quote As String = """"
For Each item In CheckedListBox1.Items
MessageBox.Show("Item with id: " + item.GetType.ToString + _
'Problem
is on this line
" is: " +

CheckedListBox1.GetItemCheckState(CheckedListBox1. Items.IndexOf(item)).ToStr
ing() + ".")
Next

The segment item.GetType.ToString returns System.String which is
confusing me because I think it means that the objects in the
checkedlistbox collection are string objects and not the objects
themselves, which would explain why I can't reference a member of the
punch object (id). Is this correct?


Right
If it is, how can I do this so that I get the object's time property
for each indexed collection? For example, I am wanting:

checkedlistbox1 index = 0 results in this messagebox: Item with ID:
932 is: unchecked
where '932' is the ID property of the time object that was loaded
into the checkedlistbox


As you didn't add the objects to the listbox, only a string, there is no
relation to the original object.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Nov 20 '05 #7

P: n/a
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Thanks for teh reply...Okay, so how can I add the object itself to
the checkedlistbox?


CheckedListBox1.Items.Add(result(j))

The listbox displays the result of the object's ToString function.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #8

P: n/a
"Derek Martin" <dm*****@DONTSPAMMEokstate.edu> schrieb
Thanks for teh reply...Okay, so how can I add the object itself to
the checkedlistbox?


CheckedListBox1.Items.Add(result(j))

The listbox displays the result of the object's ToString function.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.