473,505 Members | 15,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Binding combo box problem

Imports System.Data.OleDb
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Windows.Forms

Public Class Form1
Inherits System.Windows.Forms.Form

I am trying to simple bind a combo box to a data source per the code
below in the load procedure. It does not produce any result on the
combo box. The code for the text box works fine and the code for the
combo box will work if I change the property from SelectedValue to
Text. Any suggestions?

Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;data
source=c:\\northwind.mdb"

Dim conn As New OleDbConnection(conStr)
Dim sqlStr As String = "SELECT * FROM Orders"
Dim da As New OleDbDataAdapter(sqlStr, conn)
Dim ds As New DataSet
Dim kwds As New DataSet

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

da.Fill(kwds, "Orders")
Dim bmbOrders As BindingManagerBase
bmbOrders = Me.BindingContext(kwds, "Orders")
TextBox1.DataBindings.Add("Text", kwds, "Orders.CustomerID")
ComboBox2.DataBindings.Add("SelectedValue", kwds,
"Orders.CustomerID")
ComboBox2.ValueMember = "ShipCity"

End Sub
Nov 20 '05 #1
1 1543
Hi,

Combobox2.DataSource = kwds.Tables("Orders")
Combobox2.DisplayMember = "ShipCity"
Combobox2.ValueMember = "CustomerID"

Ken
----------------------------
"KevinW" <be****@msn.com> wrote in message
news:ff**************************@posting.google.c om...
Imports System.Data.OleDb
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Windows.Forms

Public Class Form1
Inherits System.Windows.Forms.Form

I am trying to simple bind a combo box to a data source per the code
below in the load procedure. It does not produce any result on the
combo box. The code for the text box works fine and the code for the
combo box will work if I change the property from SelectedValue to
Text. Any suggestions?

Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;data
source=c:\\northwind.mdb"

Dim conn As New OleDbConnection(conStr)
Dim sqlStr As String = "SELECT * FROM Orders"
Dim da As New OleDbDataAdapter(sqlStr, conn)
Dim ds As New DataSet
Dim kwds As New DataSet

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

da.Fill(kwds, "Orders")
Dim bmbOrders As BindingManagerBase
bmbOrders = Me.BindingContext(kwds, "Orders")
TextBox1.DataBindings.Add("Text", kwds, "Orders.CustomerID")
ComboBox2.DataBindings.Add("SelectedValue", kwds,
"Orders.CustomerID")
ComboBox2.ValueMember = "ShipCity"

End Sub

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14670
by: Shravan | last post by:
Hi, How can I bind DataRow array to ComboBox. I tried setting DataSource -> DataRow Array DisplayMember -> ColumnName But it was showing "System.Data.DataRow" for every item in the...
1
5299
by: Sachin Kuchinad | last post by:
Hi All I am using .NET Framework version 1.0.3705 to build a website. Now i have made a webform and on that i have added a dropdown to the page I bind this listbox to a datareader . This does...
0
4779
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
10
1887
by: Richard | last post by:
I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind. However I have a combo box which gets its...
0
1797
by: Roger Odermatt | last post by:
Hello I have binding a class to a DataGridView and this class have a property from another class and this i want binding to a DataGridViewComboBoxColumn. So when i change a item in the Combo and...
0
1386
by: Tommaso Caldarola | last post by:
2.0 - No Typed DataSet. My custom object implements all the needed interface (IList, IBindingList, ITypedList) in order to manage complex binding. With DataGridView control I have no problem. ...
1
9795
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt;...
3
2433
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
0
1927
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable,...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.