Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2005

Tip: Looking for answers? Try searching our database.

Checked ListBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Hughes - 04 Oct 2005 07:58 GMT
Hi,

I am using the checked list box to display my list but I have 2 columns, ID
and Name. I want the ID to be hidden and used in the SelectedIndexChanged
method to populate another ListBox. I cannot see how to do this with this
control?

Anyone can help me in the right direction?

Thanks.
Claes Bergefall - 05 Oct 2005 09:48 GMT
Put custom objects in the listbox, where each object implements a
Name and an ID property:

Public Class MyData
   Private m_name As String
   Private m_id As Integer

   Public Sub New(name As String, id As Integer)
       m_name = name
       m_id = id
   End Sub

   Public Property Name As String
       Get
           Return m_name
       End Get
       Set(value As String)
           m_name = value
       End Set
   End Property

   Public Property ID As Integer
       Get
           Return m_id
       End Get
       Set(value As Integer)
           m_id = value
       End Set
   End Property

   Public Overrides Function ToString() As String
       Return Name
   End Function
End Class

...
myListBox.Items.Add(New MyData("peter", 248745))
...
Dim data As MyData = CType(myListBox.SelectedItem, MyData)
'Do stuff with myData.Name and MyData.ID

    /claes

> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.