?
Solved

Databinding Combobox

Posted on 2008-06-09
1
Medium Priority
?
1,524 Views
Last Modified: 2013-11-26
Hi

 I have a combobox that I use databinding on.

Me.cboEmploymentCondition.DataBindings.Add(New System.Windows.Forms.Binding("Text", m_tbl_BindingSourceEmployed, "EmploymentCondition", True))

The problem is not if there are any data in the DB that matches the values in the combobox it's when it dosen't. If the data dosen't match any of the texts that's in the combobox it keeps the parent value.

So if I "send" "Test1" to the cbo it shows  "Test1" if this text is in the combobox.
If I then "send" "Test2" and that text dosen't exist in the cbo it will still show the text "Test1".
 If the text is missing I what the box to show a empty row (no text).

Is this possible to fix this?

I found this, but I can't get it to work
http://windowsclient.net/blogs/faqs/archive/2006/07/12/how-can-i-add-a-null-or-dbnull-entry-to-my-bound-combobox.aspx
/* Create a new Customer                          */
Customer cust = new Customer("Joe", null);
 
/* Add null value                                       */
DataRow row = statesTable.NewRow();
 
/* Enter a null row (ComboBox will show blank)          */
row["Name"] = "";
row["Code"] = DBNull.Value;
 
/* Add the row to DataTable                             */
statesTable.Rows.Add(row);
 
/* Bind the States ComboBox to the states DataTable     */
this.statesCB.DisplayMember = "Name";
this.statesCB.ValueMember = "Code";
this.statesCB.DataSource = statesTable;
 
/* Bind the ComboBox SelectedValue to the customer      */
/* business object                                      */
this.statesCB.DataBindings.Add("SelectedValue", cust, "StateID", true);

Open in new window

0
Comment
Question by:AWestEng
1 Comment
 
LVL 1

Accepted Solution

by:
AWestEng earned 0 total points
ID: 21784740
Ok then I will try to answer the question myself.

What I can understand from all the stuff I bben reading is the problem a related to a known "bug" in the combobox that is the main problem.

If I use a DevExpress combobox is works perfect.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

830 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