Solved

Databinding Combobox

Posted on 2008-06-09
1
1,506 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Paging GridView 7 34
Need an intro to -- .Net SQL Authorization Manager 7 49
Achieve json result 2 34
XML & .net 5 21
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

762 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

23 Experts available now in Live!

Get 1:1 Help Now