Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

Problem Displaying bound Data in a Combobox bound to a datatable

$
0
0
Folks,

I'm building a Winform app that loads 1 record at a time according to a set of criteria (not relevant to this) in VB Exrpess 2010

I am binding a combobox in code to a specific field

cb.DataSource = Nothing
cb.DataBindings.Clear()

then

cb.DataBindings.Add("Text", dt, "FIELD")

My problem occurs when a previously saved record (that populates the FIELD) is reloaded. Instead of seeing the previously saved FIELD value (String)
as I would expect from a bound cb I see a retained value from the previous record. It is as though the cb is no being 'cleared' and not displaying the value in the FIELD it is bound to.

Textboxes bound the same way with similar code don't behave this way and always display the value from the Field they are bound to.

I have experimented with cb.selectedindex = -1 but while this clears the cb it doesn't resolve the problem of the bound data not being displayed as each record is (re-loaded)

Can anyone help?

Many thanks

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>