Solved

ComboBox wont bind! Windows App

Posted on 2008-06-15
5
246 Views
Last Modified: 2013-11-26
Below code wont bind the control when I run the app, tried using the extender on the control to set up its binding source and that doesn't work either...any ideas?

I've set the below code to run when the form loads and also from a button click but doesn't do anything.

Thanks!
MyComboBox.DataSource = MyDataSet.Tables("Customers")
        MyComboBox.DisplayMember = "CompanyName"
        MyComboBox.ValueMember = "CompanyID"

Open in new window

0
Comment
Question by:garethh86
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:zveljkovic
ID: 21789790
Hi. Is MyComboBox.DataBind(); helping after that ?
0
 
LVL 7

Author Comment

by:garethh86
ID: 21789813
databind is not a member of combobox, i think that would work in ASP.Net but this is a windows VB.Net app. Can't find anything similiar to that effect either...i'm beggining to wonder if I should be connecting to the dataset or the dataset tableadapter...stabbing wildy in the dark though when I enter code - nothing seems to work with that and this conforms to the example on MSDN...I think you may be on the correct track though.
0
 
LVL 4

Accepted Solution

by:
zveljkovic earned 500 total points
ID: 21789914
Sorry for not looking throughly. Visual Basic is my taboo programing language so i tested in c#.
 I have created a Sql 2005 database with table Table1 which has fields "asdf" and "qwer". Then i added the data set and drag & dropped the table from Server Explorer onto DataSet designer. After that i added the on load event with this code:

		private void Form1_Load(object sender, EventArgs e)
		{
			Table1TableAdapter adapter = new Table1TableAdapter();
			DataSet1 ds = new DataSet1();
			adapter.Fill(ds.Table1);
 
 
			comboBox1.DataSource = ds.Table1;
			comboBox1.DisplayMember = "asdf";
			comboBox1.ValueMember = "qwer";
 
 
		}

Open in new window

0
 
LVL 7

Author Comment

by:garethh86
ID: 21790011
Pure Gold!

Incase anyone needs this in VB codes below.

Thanks for your help!
    Private Sub BindComboBox()
 
        Dim adapter As New Table1TableAdapter()
        Dim ds As New MyDataSet()
        adapter.Fill(ds.Table1)
 
        MyComboBox.DataSource = ds.Table1
        MyComboBox.DisplayMember = "CompanyName"
        MyComboBox.ValueMember = "CompanyID"
    End Sub

Open in new window

0
 
LVL 4

Expert Comment

by:zveljkovic
ID: 21790040
No thank you :)
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question