Solved

ComboBox wont bind! Windows App

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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