473,394 Members | 2,002 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,394 software developers and data experts.

setting a winforms combobox datasource at runtime

Hi i want to know how to do this:

i have a combobox in my app that is allready binded to a datatable and
has it properties valuemember and displaymember
now i want at runtime to assign to it another table...

this is the code im ussing in order to assign the new datasource but it
throwns an exception : unable to bind to a new valuemember

With Me.cboPayers
.DataBindings.Clear()
.DataSource = Nothing
.DataSource = payers.GetTable
.DisplayMember = "Descrip"
.ValueMember = "idPayee" 'here is where fails !!!
End With

thanks in advance
Nov 21 '05 #1
1 5977
Hi,

I have no problem changing the value member this way.

With ComboBox1

..DataSource = ds.Tables("Employee")

..DisplayMember = "LastName"

..ValueMember = "FirstName"

End With

With ComboBox1

..DataSource = ds.Tables("Orders")

..DisplayMember = "OrderID"

..ValueMember = "OrderDate"

End With

Ken

---------------------------

"Ariel Gimenez" <arielgimenez__arroba__hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi i want to know how to do this:

i have a combobox in my app that is allready binded to a datatable and
has it properties valuemember and displaymember
now i want at runtime to assign to it another table...

this is the code im ussing in order to assign the new datasource but it
throwns an exception : unable to bind to a new valuemember

With Me.cboPayers
.DataBindings.Clear()
.DataSource = Nothing
.DataSource = payers.GetTable
.DisplayMember = "Descrip"
.ValueMember = "idPayee" 'here is where fails !!!
End With

thanks in advance

Nov 21 '05 #2

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

Similar topics

0
by: John Bailo | last post by:
From my application I launch a subform. This form has a combobox that populates from a datasource, that I've loaded into an array. When I set the combobox equal to the datasource: ...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
7
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well....
7
by: Saber | last post by:
What's wrong here? Sub ShowDG() DsIllness1.Clear() DsIllness1.tblIllness.illIDColumn.ColumnMapping = MappingType.Hidden DsIllness1.tblIllness.illDescColumn.ColumnMapping = MappingType.Hidden ...
3
by: dbuchanan | last post by:
These setting mystify me for these reasons. *SelectedItem* - Help says that 'SelectedItem' gets or sets the currently selected item in the combobox. *SelectedValue* - Help says that...
1
by: progressdll | last post by:
I'm trying to change the behaviour of setting the DataSource property of combobox. Here is the behaviour I now see. Setting the DataSource property of combobox to an ArrayList will visual...
5
by: Crazy Cat | last post by:
Hi all, I have combobox that is bound to a custom object collection thusly Dim collection As List(Of StructureType) = StructureType.FindStructureTypes(SharedObjects.StructureTypes,...
2
by: samueltilden | last post by:
This problem should be simple. I am using Visual Studio 2003, Version 1.1 I am writing a desktop application in which I am binding a DataTable to the DataSource of a ComboBox. // I have...
1
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I generally work on web apps, but I am dealing with a Winform right now and may be missing something really basic. I have a combobox and I would like to know what value has been selected....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.