ComboBox wont bind! Windows App

Posted on 2008-06-15
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.

MyComboBox.DataSource = MyDataSet.Tables("Customers")

        MyComboBox.DisplayMember = "CompanyName"

        MyComboBox.ValueMember = "CompanyID"

Open in new window

Question by:garethh86
  • 3
  • 2

Expert Comment

ID: 21789790
Hi. Is MyComboBox.DataBind(); helping after that ?

Author Comment

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.

Accepted Solution

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();


			comboBox1.DataSource = ds.Table1;

			comboBox1.DisplayMember = "asdf";

			comboBox1.ValueMember = "qwer";


Open in new window


Author Comment

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()


        MyComboBox.DataSource = ds.Table1

        MyComboBox.DisplayMember = "CompanyName"

        MyComboBox.ValueMember = "CompanyID"

    End Sub

Open in new window


Expert Comment

ID: 21790040
No thank you :)

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing IIS after Visual Studio 2015 Community Edition 5 45
Tool Box 2 31
Export import database 4 39
Entity Framework 7 27
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

943 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now