Solved

ComboBox wont bind! Windows App

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

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)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…

738 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