Wrox Programmer Forums
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 22nd, 2006, 06:08 AM
Authorized User
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Issue Binding to ComboBox.

Dear Friends,

Please help me solve this problem(see source code on flollowing): When form load, in combo box will have 3 items with description what I would. But when I click Select button to show it's value then it will return: "ExamID" is the same with property that I assign for it while bind data.
For Example:
DisplayMember: Exam 1, Exam2 ,...OK
ValueMember: "ExamID" string. what I need: 1,2,...

I tried but I could not debug this problem.

Please help me....

Thank you very much


Private Sub BindData()

   Dim conn As New OleDbConnection(DbObject.CONNECTION_STRING)
   Dim cmd As New OleDbCommand("SELECT ExamID, Description FROM ExamEN", conn)
   Dim adapter As New OleDbDataAdapter(cmd)
   Dim ds As New DataSet

   adapter.Fill(ds, "Exam")

   With listExam
      .ValueMember = "ExamID"
      .DisplayMember = "Description"
      .DataSource = ds.Tables("Exam")
   End With

End Sub

Private Sub SelectExam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   'Bind data to combobox
End Sub

Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click

   Dim str As String

   str = Me.listExam.ValueMember

End Sub

Old February 22nd, 2006, 09:38 PM
Authorized User
Join Date: Aug 2003
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts

OK, thank you very much.

Problem has been solved. I was doting!


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding ComboBox inside ListView problem gunnjamie Windows Presentation Foundation 1 July 17th, 2008 02:13 PM
Binding a comboBox to update a listView Amethyst1984 VB How-To 2 February 28th, 2006 03:07 PM
data binding a combobox ozPATT Excel VBA 1 November 16th, 2005 08:17 AM
binding combobox to sqlreader? drachx General .NET 6 October 14th, 2004 07:10 PM
ComboBox Data Binding bmains VB.NET 0 October 5th, 2004 02:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.