Solved

ComboBox wont bind! Windows App

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

9 Experts available now in Live!

Get 1:1 Help Now