Results 1 to 4 of 4

Thread: [RESOLVED] DisplayMember

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    Resolved [RESOLVED] DisplayMember

    hello Genius ...!!!!!!
    could not get selected item text in combobox selectedindex changed event
    return value is "System.Data.DataRowView"
    Datasource Code:
    1. Dim TABLE_NAME As New DataTable
    2.                         _ADOBTER.Fill(TABLE_NAME)
    3.                         ComboBox1.DataSource = TABLE_NAME
    4.                         ComboBox1.DisplayMember = "CUSTNAME"
    5.                         ComboBox1.ValueMember = "CUSTNAME"
    6.  
    7.   Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    8.      msgbox(ComboBox1.SelectedItem.Tostring)  '"System.Data.DataRowView"
    9.  msgbox(ComboBox1.SelectedText.Tostring)  '"System.Data.DataRowView"
    10.  
    11.     End Sub

    want to get the value from the combobox but i always getting ""System.Data.DataRowView"
    help me please
    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DisplayMember

    The Text and SelectedText properties of a ComboBox work exactly the same way as for a TextBox. How would you get the data you want if it was a TextBox?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    60

    Re: DisplayMember

    yes...i solved it according to your suggestion JMC sir i just got this below code from your an another post
    provided by you "GetItemText"
    msgbox(ComboBox1.GetItemText(Combobox1.SeletectedItem).Tostring) ...

    Thanks JMC

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] DisplayMember

    First up, GetItemText returns a String, so calling ToString on the result is rather pointless. Second, this:
    Code:
    ComboBox1.GetItemText(Combobox1.SeletectedItem)
    does exactly the same as this:
    Code:
    ComboBox1.Text
    Given that you were already using SelectedText and I mentioned SelectedText and Text in my previous post, did that not suggest that you should have used Text?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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