473,386 Members | 1,733 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.

Assigning datasource to combo box

Hi

I am using below code to fill the drop down list of a combo box from a table
in the dataset;

Dim dv As New DataView(ds.Companies)
Me.txtParent.DataSource = dv
Me.txtParent.DataMember = "Company"
dv.Dispose()
dv = Nothing

Unfortunately no data turns up in combo box. What am I doing wrong?

Thanks

Regards
Feb 11 '08 #1
5 2472
"John" <Jo**@nospam.infovis.co.ukschrieb:
I am using below code to fill the drop down list of a combo box from a
table in the dataset;

Dim dv As New DataView(ds.Companies)
Me.txtParent.DataSource = dv
Me.txtParent.DataMember = "Company"
dv.Dispose()
dv = Nothing

Unfortunately no data turns up in combo box. What am I doing wrong?
Remove the last two lines. You must not destroy the data source as long as
the control depends on it. In addition, setting local variables to
'Nothing' is (with very few exception) not the best style.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 11 '08 #2
Hi

Thanks. No luck I am afraid. I have tried all this;

Dim dv As New DataView(ds.Clients)

1. Me.txtParent.DataSource = "dv.company"

2. Me.txtParent.DataSource = dv
Me.txtParent.DataMember = "company"

3. Me.txtParent.DataSource = ds.Clients
Me.txtParent.DataMember = "company"

Any ideas? I have tested ds.Clients.Count and it returns more than zero so
there are records in the dataset.

Thanks

Regards

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:uE**************@TK2MSFTNGP06.phx.gbl...
"John" <Jo**@nospam.infovis.co.ukschrieb:
>I am using below code to fill the drop down list of a combo box from a
table in the dataset;

Dim dv As New DataView(ds.Companies)
Me.txtParent.DataSource = dv
Me.txtParent.DataMember = "Company"
dv.Dispose()
dv = Nothing

Unfortunately no data turns up in combo box. What am I doing wrong?

Remove the last two lines. You must not destroy the data source as long
as the control depends on it. In addition, setting local variables to
'Nothing' is (with very few exception) not the best style.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 11 '08 #3
John,

Are you sure you have the right control. I see seldom people call a combobox
txt that is mostly (forever) used for a textbox.

You have to set the displaymember in the way you did it as in 2 and 3.
However, normally the valuemember is set as well.

Cor

Feb 12 '08 #4
You need to set the display member and value member. They can be the same
thing. They must be what field in the dataset you want to use.

Me.txtParent.DataSource = ds.Clients
Me.txtParent.DisplayMember = "CompanyName"
Me.txtParent.ValueMember = "CompanyID"

RobinS.
GoldMail, Inc.
------------------------------------
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:OP**************@TK2MSFTNGP03.phx.gbl...
Hi

Thanks. No luck I am afraid. I have tried all this;

Dim dv As New DataView(ds.Clients)

1. Me.txtParent.DataSource = "dv.company"

2. Me.txtParent.DataSource = dv
Me.txtParent.DataMember = "company"

3. Me.txtParent.DataSource = ds.Clients
Me.txtParent.DataMember = "company"

Any ideas? I have tested ds.Clients.Count and it returns more than zero so
there are records in the dataset.

Thanks

Regards

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:uE**************@TK2MSFTNGP06.phx.gbl...
>"John" <Jo**@nospam.infovis.co.ukschrieb:
>>I am using below code to fill the drop down list of a combo box from a
table in the dataset;

Dim dv As New DataView(ds.Companies)
Me.txtParent.DataSource = dv
Me.txtParent.DataMember = "Company"
dv.Dispose()
dv = Nothing

Unfortunately no data turns up in combo box. What am I doing wrong?

Remove the last two lines. You must not destroy the data source as long
as the control depends on it. In addition, setting local variables to
'Nothing' is (with very few exception) not the best style.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 13 '08 #5
Could try DaisyCombo released by www.springsys.com.
-martin
Hi

I am using below code to fill the drop down list of a combo box from a
table in the dataset;

Dim dv As New DataView(ds.Companies)
Me.txtParent.DataSource = dv
Me.txtParent.DataMember = "Company"
dv.Dispose()
dv = Nothing

Unfortunately no data turns up in combo box. What am I doing wrong?

Thanks

Regards

Feb 20 '08 #6

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

Similar topics

0
by: RvGrah | last post by:
I'm trying to speed up my coding by not doing so much manually, use the automated tools more. I'm binding the Datasource, DisplayMember, and ValueMember to a Combo. The automation also puts a...
3
by: Richard Ryerson | last post by:
I have a general DataGridComboBoxColumn that I built using the Example in the .NET 2003 Combined Collection help file (that was a data time picker). I am able to assign a data source and display...
1
by: Alejandro González | last post by:
Hi I have a combobox binded to a Datatable something like combo.DataSource = dt.DefaultView; combo.DisplayMember = "descField"; combo.ValueMember = "valueField"; it works fine.
1
by: Alejandro González | last post by:
Hi I have a combobox binded to a Datatable something like combo.DataSource = dt.DefaultView; combo.DisplayMember = "descField"; combo.ValueMember = "valueField"; it works fine.
0
by: Dustin Davis | last post by:
I've found you can use arrays as a datasource for combo boxes. Is it possible to set the index value of the array to be used as the value member for the combo box? I'm really just looking for...
4
by: Dave White | last post by:
Hello Everyone, I have created two tables to track my students' lessons. Each student is responsible for most, but not all. of the lessons. I've tried a junction table but I can't figure out...
1
by: weird0 | last post by:
I am assigning an arrlist to the datasource property of the datagridview. In short, i want to update the datagridview. But the moment, i assign it. The application crashes. It does not display the...
1
by: RP | last post by:
I have a DataSet with few DataTables in it. One of the table has only one column. I want to show all the records of this DataTable when focus is on the combo box. How to set the combo box...
1
nev
by: nev | last post by:
Happy Easter to all! I have a problem with a datagridview. I placed code in a button click event as follows: dim dtt as datatable = dataset.employees.copy dtt.DefaultView.RowFilter = "='" &...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.