By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Combobox not refreshing when linking to dataset

P: n/a
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)d t = 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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Nov 21 '05 #2

P: n/a
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
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message news:eO**************@TK2MSFTNGP11.phx.gbl...
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

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.