Results 1 to 23 of 23

Thread: How to SET the value of a Listview / Combobox item?

Hybrid View

  1. #1
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [RESOLVED] How to SET the value of a Listview / Combobox item?

    use
    Code:
    Me.ListBox1.SelectedItem.ToString()
    but you will need to override the ToString method of your class like so
    Code:
        Private Class Person
    
            Private _Name As String
            Private _PhoneNumber As String
    
            Public Sub New(ByVal Name As String, ByVal PhoneNumber As String)
                _Name = Name
                _PhoneNumber = PhoneNumber
            End Sub
    
            Public Sub New()
    
            End Sub
    
            Public Property Name() As String
                Get
                    Return _Name
                End Get
                Set(ByVal value As String)
                    _Name = value
                End Set
            End Property
    
            Public Property PhoneNumber() As String
                Get
                    Return _PhoneNumber
                End Get
                Set(ByVal value As String)
                    _PhoneNumber = value
                End Set
            End Property
    
            Public Overrides Function ToString() As String
                Return _Name
            End Function
    
        End Class
    Last edited by bmahler; Aug 29th, 2007 at 12:47 PM.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  2. #2

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    35

    Re: [RESOLVED] How to SET the value of a Listview / Combobox item?

    Thanks.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    35

    Re: [RESOLVED] How to SET the value of a Listview / Combobox item?

    Can I sort the people array list by name?

    people.sort()
    doesn´t work. It stops with error "InvalidOperationException"
    Last edited by belinea2003; Nov 4th, 2007 at 04:00 PM.

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    35

    Re: [RESOLVED] How to SET the value of a Listview / Combobox item?

    No idea?

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    35

    Re: How to SET the value of a Listview / Combobox item?

    Really no way to sort the people alphabetically ?

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    35

    Re: How to SET the value of a Listview / Combobox item?

    I have another problem.

    I can select a contact in the dropdown by it it´s telephone number

    Code:
    Me.listbox1.SelectedValue = "555-125-4587"
    But I cannot select a contact in the dropdown by it´s name.

    Code:
    Me.listbox1.SelectedItem = "John Doe"
    When I try this, the dropdown stays at the current selected entry.

    Can you help me again bmahler? Thank you...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width