Combobox not refreshing when linking to dataset

S

Simon Verona

I have a combobox that is contained within a user control.

Whilst the application is running, I'm attaching the combobox to a new
dataset. The problem I'm getting is that the combobox doesn't appear to
reflect the new dataset. The same code seems to work fine if the combobox
is set to the dataset on initialisation. What have I done wrong?

The code in full that I'm using to update the dataset and attach to the
combobox is as follows (the object jtmp is a link to a properietary
database, but I can see it cycling through this correctly).

dct = jtmp.ExtractDA(LookupAmc).DCount(m_DmsControl.VM)dt = New DataTable
ds = New DataSet
dv = New DataView
dt.TableName = "Data"
dt.Columns.Add("Id", System.Type.GetType("System.String"), "")
dt.Columns.Add("Description", System.Type.GetType("System.String"), "")
ds.Tables.Add(dt)
dv = ds.Tables("Data").DefaultView
Dim dr As DataRow
For cnt = 1 To dct
Try
If jtmp.Extract(m_LookupAmc, cnt).StartsWith("*") = False Then
Try
dr = dt.NewRow
dr.Item("Id") = cnt
dr.Item("Description") = jtmp.Extract(m_LookupAmc, cnt)
dt.Rows.Add(dr)
Catch
End Try
End If
Catch
End Try
Next cnt
dv.Sort = "Description"
txtLookup.ValueMember = Nothing
txtLookup.DataSource = Nothing
txtLookup.DisplayMember = Nothing
txtLookup.DisplayMember = "Description"
txtLookup.ValueMember = "Id"
txtLookup.DataSource = dv
txtLookup.Refresh()


Any clues as to what I've done wrong?

Thanks in advance

Simon
 
C

Cor Ligthert [MVP]

Simon,

I think that you first of all have to remove all the code that you created
around your code to suppress the showing of all normal errors (without any
action at all).

Than the next problem can be done, however as you show it, have you
declared your usercontrol as bellow? Otherwise the code should not work in
my opinion or you should have created a lot of extra properties..

txtLookup as control
inherits Combobox

Is that true?

Cor
 
S

Simon Verona

The usercontrol inherits from System.Windows.Forms.UserControl - this is because the usercontrol also has a button on it as well.

I've put some traps in the "catch" areas of my try/catch/end try to make sure it's not hitting an error, which it doesn't appear to be.

I'm not sure why not inheriting from UserControl should in itself cause a problem, surely this is how the usercontrol is supposed to work?

Regards
Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top