WPF Combobox Advise-VBForums
Results 1 to 2 of 2

Thread: WPF Combobox Advise

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2012
    Location
    Sri Lanka
    Posts
    5

    WPF Combobox Advise

    Hi,

    I have a stored procedure which returns UserID and UserName.

    I need to display UserID|UserName in a dropdown and when a selection is made, only UserID needs to be displayed.

    Could someone please direct me on how to achieve this?

    Many Thanks.

  2. #2
    New Member
    Join Date
    Jan 2013
    Posts
    1

    Re: WPF Combobox Advise

    Quote Originally Posted by reez88 View Post
    Hi,

    I have a stored procedure which returns UserID and UserName.

    I need to display UserID|UserName in a dropdown and when a selection is made, only UserID needs to be displayed.

    Could someone please direct me on how to achieve this?

    Many Thanks.
    Try this:

    Public Class clsMyProcedure
    Dim _us as String, _id as Integer

    Public Sub New (us as String, id as Integer)
    _us = us
    _id = id
    End Sub

    Public ReadOnly Property UserName as String
    Get
    Return _us
    End Get
    End Property

    Public ReadOnly Property UserID as Integer
    Get
    Return _id
    End Get
    End Property

    Public Function Overrides ToString () as String
    Return _us
    End Function
    End Class

    You store a collection of objects clsMyProcedure and you get the UserName from ToString Function. You also have available the UserID from the UserID property.

    You can declare a generic procedure like a list:

    Dim myList as new List(Of clsMyProcedure)

    myList.Add(New clsMyProcedure("John", 1))

    I hope that help 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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.