Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ComboBox wont bind! Windows App

Posted on 2008-06-15
5
Medium Priority
?
252 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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