Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 22nd, 2006, 05:08 AM
Authorized User
 
Join Date: Aug 2003
Location: HCM, HCM, Vietnam.
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

SOURCE CODE:

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

   adapter.Dispose()
End Sub

Private Sub SelectExam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   'Bind data to combobox
   BindData()
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

   MessageBox.Show(str)
End Sub

L.V.L
__________________
L.V.L
Reply With Quote
  #2 (permalink)  
Old February 22nd, 2006, 08:38 PM
Authorized User
 
Join Date: Aug 2003
Location: HCM, HCM, Vietnam.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, thank you very much.

Problem has been solved. I was doting!

L.V.L
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 02:07 PM
data binding a combobox ozPATT Excel VBA 1 November 16th, 2005 07: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



All times are GMT -4. The time now is 08:23 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.