473,385 Members | 1,907 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,385 software developers and data experts.

comboBox datasource

Hello I want to add data to comboBox from a dataset and doing it this
way:

public OpenDatabase(DataSet ds_db)
{
this.comboBox1=new ComboBox();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
InitializeComponent();

}

if I am erasing the line :this.comboBox1=new ComboBox()- I get an error
,if I leave it the combobox is empty . How to add the data to it?
Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #1
10 5648
Juli,

Probably is the reason that you have already set the property datasource and
it prevent to add it double. (maybe in the desinger)

You can set the datasource to null by the way.

Cor
Nov 17 '05 #2
Juli,

Probably is the reason that you have already set the property datasource and
it prevent to add it double. (maybe in the desinger)

You can set the datasource to null by the way.

Cor
Nov 17 '05 #3
Hello,
I checked it and in the design mode there is no value at
DataSource.Maybe there is something besides this that prevents from the
data to be shown in a comboBox?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
Hello,
I checked it and in the design mode there is no value at
DataSource.Maybe there is something besides this that prevents from the
data to be shown in a comboBox?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5
Ron
Hi juli jul.
If the combobox is on a form, then InitializeComponent() will instantiate
the combobox to a new combobox, thus wiping out the settings you have given
it. To fix this, move the InitialiseComponent() line to above your code and
remove the line this.comboBox1=newComboBox(). You code should look like:

public OpenDatabase(DataSet ds_db)
{
InitializeComponent();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
}

By the way, as far as I understand, InitialiseComponent() should only be
called in the form constructor.

HTH
Ron.
"juli jul" <ju******@yahoo.com> wrote in message
news:uM**************@TK2MSFTNGP14.phx.gbl...
Hello I want to add data to comboBox from a dataset and doing it this
way:

public OpenDatabase(DataSet ds_db)
{
this.comboBox1=new ComboBox();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
InitializeComponent();

}

if I am erasing the line :this.comboBox1=new ComboBox()- I get an error
,if I leave it the combobox is empty . How to add the data to it?
Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #6
Ron
Hi juli jul.
If the combobox is on a form, then InitializeComponent() will instantiate
the combobox to a new combobox, thus wiping out the settings you have given
it. To fix this, move the InitialiseComponent() line to above your code and
remove the line this.comboBox1=newComboBox(). You code should look like:

public OpenDatabase(DataSet ds_db)
{
InitializeComponent();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
}

By the way, as far as I understand, InitialiseComponent() should only be
called in the form constructor.

HTH
Ron.
"juli jul" <ju******@yahoo.com> wrote in message
news:uM**************@TK2MSFTNGP14.phx.gbl...
Hello I want to add data to comboBox from a dataset and doing it this
way:

public OpenDatabase(DataSet ds_db)
{
this.comboBox1=new ComboBox();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
InitializeComponent();

}

if I am erasing the line :this.comboBox1=new ComboBox()- I get an error
,if I leave it the combobox is empty . How to add the data to it?
Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #7

Thank you very much - it was really a stupid mistake I did:)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #8

Thank you very much - it was really a stupid mistake I did:)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #9
how about ValueMember??
u must alos set ValueMember and DisplayMember

"Ron" <no***@nowhere.com> wrote in message
news:#L**************@TK2MSFTNGP15.phx.gbl...
Hi juli jul.
If the combobox is on a form, then InitializeComponent() will instantiate
the combobox to a new combobox, thus wiping out the settings you have given it. To fix this, move the InitialiseComponent() line to above your code and remove the line this.comboBox1=newComboBox(). You code should look like:

public OpenDatabase(DataSet ds_db)
{
InitializeComponent();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
}

By the way, as far as I understand, InitialiseComponent() should only be
called in the form constructor.

HTH
Ron.
"juli jul" <ju******@yahoo.com> wrote in message
news:uM**************@TK2MSFTNGP14.phx.gbl...
Hello I want to add data to comboBox from a dataset and doing it this
way:

public OpenDatabase(DataSet ds_db)
{
this.comboBox1=new ComboBox();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
InitializeComponent();

}

if I am erasing the line :this.comboBox1=new ComboBox()- I get an error
,if I leave it the combobox is empty . How to add the data to it?
Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 17 '05 #10
how about ValueMember??
u must alos set ValueMember and DisplayMember

"Ron" <no***@nowhere.com> wrote in message
news:#L**************@TK2MSFTNGP15.phx.gbl...
Hi juli jul.
If the combobox is on a form, then InitializeComponent() will instantiate
the combobox to a new combobox, thus wiping out the settings you have given it. To fix this, move the InitialiseComponent() line to above your code and remove the line this.comboBox1=newComboBox(). You code should look like:

public OpenDatabase(DataSet ds_db)
{
InitializeComponent();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
}

By the way, as far as I understand, InitialiseComponent() should only be
called in the form constructor.

HTH
Ron.
"juli jul" <ju******@yahoo.com> wrote in message
news:uM**************@TK2MSFTNGP14.phx.gbl...
Hello I want to add data to comboBox from a dataset and doing it this
way:

public OpenDatabase(DataSet ds_db)
{
this.comboBox1=new ComboBox();
this.comboBox1.DataSource=ds_db.Tables[0];
this.comboBox1.DisplayMember = "name";
InitializeComponent();

}

if I am erasing the line :this.comboBox1=new ComboBox()- I get an error
,if I leave it the combobox is empty . How to add the data to it?
Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 17 '05 #11

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

Similar topics

3
by: Tamir Khason | last post by:
Why this does not work??? cb1 - combobox DataProvider.DataProvider.DS_BringRacks() - DataSet cb1.DataSource=DataProvider.DataProvider.DS_BringRacks().Tables; cb1.DisplayMember = "id"; ...
0
by: CalPARK InterNetStation | last post by:
Could anyone explain why the difference of behavior betweein Case1 and Case2 occurs? Microsoft Visual C#.NET 55607-652-0000007-18218 Windows Forms Application 1. put a TabControl on a Form...
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
8
by: Steve B. | last post by:
My Program: a local C# ADO.Net application using VS 2003 Right now I have about 5 ComboBox's which provides drop down selection entries from the same MS-Access table via a DataConnection,...
2
by: jobi | last post by:
Hi, I have this combobox which has a table from a dataset as datasource. When I click an item on the combobox-list , I would like to display (in textfield) the value from an other column that...
2
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
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...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
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...
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:
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...
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
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...

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.