PC Review


Reply
Thread Tools Rate Thread

CheckedListBox Question

 
 
Derek Martin
Guest
Posts: n/a
 
      7th Apr 2004
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(objecttest1.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


 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      7th Apr 2004
"Derek Martin" <(E-Mail Removed)> 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(objecttest1.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

 
Reply With Quote
 
Derek Martin
Guest
Posts: n/a
 
      7th Apr 2004
Thanks for teh reply...Okay, so how can I add the object itself to the
checkedlistbox?

Thanks!
Derek



"Armin Zingler" <(E-Mail Removed)> wrote in message
news:40744565$0$26129$(E-Mail Removed)...
> "Derek Martin" <(E-Mail Removed)> 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(objecttest1.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
>



 
Reply With Quote
 
Derek Martin
Guest
Posts: n/a
 
      7th Apr 2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thanks for teh reply...Okay, so how can I add the object itself to the
> checkedlistbox?
>
> Thanks!
> Derek
>
>
>
> "Armin Zingler" <(E-Mail Removed)> wrote in message
> news:40744565$0$26129$(E-Mail Removed)...
> > "Derek Martin" <(E-Mail Removed)> 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(objecttest1.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
> >

>
>



 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      7th Apr 2004
"Derek Martin" <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckedListBox Question Newbie Coder Microsoft VB .NET 1 3rd Dec 2006 07:57 PM
CheckedListbox Question Moondog Microsoft VB .NET 4 18th Oct 2004 11:59 PM
RE: A question about CheckedListBox. James Johnson Microsoft C# .NET 0 10th Sep 2004 02:51 PM
Question on a CheckedListBox. Manuel Canas Microsoft VB .NET 2 29th Jul 2004 01:13 AM
CheckedListBox question Stephen Haunts Microsoft Dot NET Framework Forms 1 24th Jun 2004 06:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:13 PM.