473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Why does a binding a combobox to datatable not work the same as da

If a bind a data table to a comboxbox as appose to merging the table into a
dataset the selectedvalue property does not work consistently

On loading of a form:
A datatable is created from a database with ID 1 - 10 and values associated
e.g. Red, green, blue.

An additional item is added to the datatable to reflect a non selected item
with an ID of 0 for no colour selected.

on reading of data, when a value of 0 is set to the selected value the
following error occurs:

Parameter name: '-2147483613' is not a valid value for 'index'

But if the datatable is first merged with a data set and the dataset's table
is reference to the combobox, there's no problem.
Sample code Try commented, then uncommented:

Sub Load
dtDataTable = ColoursRead()

'dsDataSet.Merge(dtDataTable)

With cboColours
.DataSource = dtDataTable
'.DataSource = _referenceData.Tables("Banks")
.DisplayMember = "Name"
.ValueMember = "pkiColourID"
End With
End Sub

Sub SelectValue()
cboColours.SelectedValue = 0
End Sub

Data:
pkiColourID Name
0 No Colour
1 Red
2 Green
3 Blue
Jul 21 '05 #1
0 1039

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

Similar topics

8
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some...
16
by: Michael C# | last post by:
I'm binding a Combobox to an Arraylist, and I'd like to set the ValueMember and DisplayMember properties of the Combobox. Is this possible, or do I need to bind to a DataTable? Thanks
4
by: Jim Shaffer | last post by:
Perhaps I have the wrong construct, or misunderstand arrays in vb (2003).... I've loaded a two-dimensional array (168 by 28) into memory as AcctArray. {Dim AcctArray (500,28) as string...} The...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
3
by: amber | last post by:
Hello, I have 6 comboboxes, that I thought I could bind to the same datasource, and have them display different 'selectedvalue's', but apparently I can't... My code is as follows: dim drv as...
0
by: Mohamed Osman | last post by:
If a bind a data table to a comboxbox as appose to merging the table into a dataset the selectedvalue property does not work consistently On loading of a form: A datatable is created from a...
0
by: bpdace | last post by:
i have a datatable 'Users' with two columns: 'FriendlyName' 'UserName' i have a datagrid with two columns that I want to bind with the 'Authors' table: 'FriendlyName' : ComboBox column...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
3
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.