-
[RESOLVED] refresh combobox values after updating its datatable and adapter
hi all - on a windows form i have a combobox called currency, it is populated by a tableadapter called exchangerate which is turn populated by a dataset called mydataset.
on form load, i issue update commands to the backend database that holds the table which populates the dataset - they work. if i look at the update to the combobox, they are not reflected until i exit and restart the app - then they're fine.
further down the formload i've tried
Code:
Me.exchangerate.Update(Me.DataSet.Currency)
Me.CurrencyComboBox.Refresh()
am i missing something silly to have the values in the combobox change and refresh at the time of the update to the database? as i said, an exit and restart of the app displays the accurate data....i can't figure this out for the life of me.
-
Re: refresh combobox values after updating its datatable and adapter
I keep seeing this sort of question over and over. All the Refresh method of any control does is redraw it on-screen. It doesn't do anything else. If the binding hasn't been updated then redrawing it will have no effect.
I would have thought that if your data was bound to the ComboBox then the control should update automatically. If it's not then you can call the ResetBindings method of the associated BindingSource.
-
Re: refresh combobox values after updating its datatable and adapter
i tried both
Code:
Me.exchangerate.Update(Me.DataSet.Currency)
me.currencybindingsource.resetbindings(false)
and
Code:
Me.exchangerate.Update(Me.DataSet.Currency)
me.currencybindingsource.resetbindings(true)
wondering if it was a schema change (wanted to be sure) - and same thing - on the opening round, the selected value of my combobox (what i'm tracking on) - is the old value on form load - exit the app, go back in, and the selected value is what it's supposed to be.....
-
Re: refresh combobox values after updating its datatable and adapter
oh and this is a sqlexpress 2005 mdf that has the table with the data in it if that makes any difference...
the combobox properties being used are data source, display member and valuemember - I'm still very green at this but also noticed a plus sign entitled 'databindings' above combobox name, but all are blank - will begin researching what those are all about next....
-
Re: refresh combobox values after updating its datatable and adapter
You wouldn't use the DataBindings property at all. That's for bind specific properties of the ComboBox to values from a list or an object. That is used more in situations like binding the Text property of a TextBox.
For a ComboBox you would use, as you said, the DataSource, DisplayMember and ValueMember. The DataSource is the list containing the data to bind. The DisplayMember is the name of the member of the bound objects to display in the control. The ValueMember is the name of the member of the bound objects whose value should be returned by the control's SelectedValue property. A common scenario is binding a DataTable via the DataSource and setting the DisplayMember and ValueMember to "Name" and "ID" respectively. That way the user sees a list of names they can choose and you can get the ID that corresponds to the selected name from the SelectedValue property.
Now, in your situation, you should be binding your DataTable to a BindingSource and then binding that to the ComboBox. It can be done in code or, if you added the DataSet in the designer, then it can also be done in the designer. You can either assign the DataTable to the BindingSource's DataSource property or else assign a DataSet to the DataSource and then the name of the DataTable to the DataMember. The BindingSource then gets assigned to the ComboBox's DataSource. If it's set up that way then any changes you make to the DataTable will be reflected in the ComboBox.
Now, reading your posts a bit more carefully, there's no reason that calling Update on a TableAdapter should cause the selection in the ComboBox to change. Update will save the changes in the DataTable to the database but those changes should already be reflected in the ComboBox because they're already in the DataTable.
I think you need to explain more clearly exactly what you're trying to do, how you're trying to do it, what you expect to happen and what does happen.
-
Re: refresh combobox values after updating its datatable and adapter
thanks for the databindings heads up - you saved me several hours of googling I'm sure.....
the short version (or at least as short as I can make it, so forgive the excessive verbiage) is as follows:
- created a sql2005 express database with a table called currency in it - fields are Currency, Rate, As_of
- i call a public function named getexchangerate() that hits yahoo finance and grabs the exchange rate .csv file for that particular currency and time of day and parses the values in to their respective pieces that correspond with the above fields in currency
- i fire up a connection to the database and call the transact-sql update command using the values retrieved above - the table updates with the values successfully
- i launch form1 which contains a combobx entitled Exchange_CB - it's display value is Currency, It's value item is Rate
- also, as a sidebar....i have a string i pass from the getexchangerate function that updates a label that contains all of the retrieved values - this also works correctly on form load (and is how i discovered the update wasn't happening on the comboboxes selectedvalue)
- when i dropdown and change the combobox, in this case from CDN to USD, the previous valuemember is displayed (ie from the last successful download) - i exit the app and go back in, and change it again and it's correct. Logic seems to tell me that my call to refresh the data is happening before the adapter is filled, but of course i don't know at this point and hence this posting....
- The combobox was created simply by dragging it on to form1 from the toolbox and then in properties i added it's datasource and display member and value member from there - not programatically....
for the record, i am far from an expert and have been at this for the last whopping 6 months now - you actually were instrumental in resolving my very first problem and several others by the way.....
- oh and lastly, the "why" i'm doing it this way - I'm doing this because the machine that this app is running on is sometimes online and sometimes not and the exchange rate is used in a calc for quotes, hence i want both the end user to actually see what the exchange rate WAS before they went offline or to see what it IS if they are, and also to store it.
I can equate this issue to the following example: "on Form A a user has a combobox called customers and a button called add customer. The Add customer button launches new form that allows the user to enter a new customer name and click save. When the user hits save and form B closes and the focus goes back to form A and they drop down the combobox, the newly added customer does not show up, yet when checking the table, it is there. if they exit the app and restart the previously added customer now shows up in the combobox list." - so ideally, how do you get the combobox to reflect the newly added record without exiting the app?
- again, just an example above - but those are my symptoms as well.....
-
Re: refresh combobox values after updating its datatable and adapter
You may have figured this out already but I thought I would post this to help someone else that may be having this issue. If you swap out my arraylist code with your tableadapter I believe it will work.
Dim arlItems As ArrayList = combobox.DataSource
arlItems.Add(New clsCombo(nNextID, "New", "", "", "", ""))
combobox.BindingContext(combobox.DataSource).SuspendBinding()
combobox.DataSource = arlitems
combobox.BindingContext(combobox.DataSource).ResumeBinding()
'Set the new item as the selected item
combobox.SelectedValue = nNextID.ToString
-
Re: refresh combobox values after updating its datatable and adapter
can' you just reset the .datasource?
combobox.DataSource = ?datasource
-
Re: refresh combobox values after updating its datatable and adapter
I thought the same thing at first but when you just try to set the datasource again it will not show any new items that you have added in the combobox.
-
Re: refresh combobox values after updating its datatable and adapter
got it - simply use the invalidate method - works great
Code:
'refresh the datasource
combobox.datasource=?datasource
'select the new field from the table to populate the combobox with
combobox.displaymember = "New Display Member"
'redraw the combobox to reflect the values
combobox.invalidate()
what a pain this one turned out to be for something so simple.....that's usually the way though - too close to the problem to see it clearly - as you can see by the date on this latest post, i stepped away from this one for quite a while.
hope this helps anybody else who has stumbled upon the same issue.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Hey people its very simple what u have to do is
Form1_Load(Nothing, Nothing)
ie make a call to form load method which reloads everything
samething works in c# too:)
belive me it works gr8 na
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
I think you guys are missing the big picture. There is a difference between a dataset and the database. A dataset is a copy of the data in the database. If you update the data in the Database's datatable you have to reload the data into the dataset datatable. Also, if you update the data in a dataset, you have to save it using the update method. Otherwise you are only changing the copy of the data, not the data. When you reload the dataset, the data you added will be missing.
This code obviously doesn't work for every scenario, just keep in mind that you have to reload the data from the table before you can see it.
Me.MachinesTableAdapter.InsertMachineName(tbxMachineName.Text)
Me.MachinesBindingSource.EndEdit()
Me.MachinesTableAdapter.Update(Me.FlowMetersDataSet.Machines)
Me.MachinesTableAdapter.Fill(Me.FlowMetersDataSet.Machines)
'Returning From a dialog
Dim Result As DialogResult
Result = dlgNewMachine.ShowDialog()
If Result = DialogResult.OK Then Me.MachinesTableAdapter.Fill(Me.FlowMetersDataSet.Machines)
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
TrippingCobras
There is a difference between a dataset and the datatable. A dataset is a copy of the data in the datatable.
a dataset is a collection of datatables + if you change the datatable it changes
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
TrippingCobras
I think you guys are missing the big picture. There is a difference between a dataset and the datatable.
There's a difference alright, but not the one you seem to think there is. A DataSet is essentially an in-memory representation of a database. A DataTable is basically an in-memory representation of a database table. Just as a database contains tables and relations between them, so a DataSet contains DataTables and DataRelations. A DataSet has a Tables property, which is a collection of DataTables, and a Relations property, which is a collection of DataRelations.
When you call Fill on a DataAdapter or TableAdapter you are populating a DataTable. Even if you pass a DataSet as an argument, you are populating one of the DataTables in its Tables collection. When you call Update on a DataAdapter or TableAdapter you are saving changes from a DataTable. Even if you pass a DataSet as an argument, you are saving changes from one of the DataTables in its Tables collection.
Just as a database table has columns to describe the data and rows to contain it, so a DataTable has a Columns property, which is a collection of DataColumns, and a Rows property, which is a collection of DataRows.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
There's a difference alright, but not the one you seem to think there is. A DataSet is essentially an in-memory representation of a database. A DataTable is basically an in-memory representation of a database table. Just as a database contains tables and relations between them, so a DataSet contains DataTables and DataRelations. A DataSet has a Tables property, which is a collection of DataTables, and a Relations property, which is a collection of DataRelations.
When you call Fill on a DataAdapter or TableAdapter you are populating a DataTable. Even if you pass a DataSet as an argument, you are populating one of the DataTables in its Tables collection. When you call Update on a DataAdapter or TableAdapter you are saving changes from a DataTable. Even if you pass a DataSet as an argument, you are saving changes from one of the DataTables in its Tables collection.
Just as a database table has columns to describe the data and rows to contain it, so a DataTable has a Columns property, which is a collection of DataColumns, and a Rows property, which is a collection of DataRows.
I meant database smart guy. You can manipulate the dataset without committing the changes to the actual database. Many people don't understand this and find themselves wondering why all of their data dissapeared. And Paul apparently hasn't figure this out either.
Chances are the people who originally asked the question are using table adapters (as in ADO.Net). People make the mistake of adding the data to the table adapter, then can't see it on the dataset because they didn't perform a fill method. Another thing that happens is that someone changes the dataset, then doesn't write the the information back to the database.
Why do I bother with you guys? The post was never really properly addressed, but you guys are sure to jump on someone adding input.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
omkarlawande
Hey people its very simple what u have to do is
Form1_Load(Nothing, Nothing)
ie make a call to form load method which reloads everything
samething works in c# too:)
belive me it works gr8 na
I have the same problem with a combobox not reflecting data changes to the database. I have beat myself silly with this problem on and off for 3 days... I tired the solution that fixed the OP's issues but my VB2010 doesn't like that code. Please explain your solution to me...
-
Re: refresh combobox values after updating its datatable and adapter
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
I have the same problem with a combobox not showing new data unless I exit the debugger and run it again. I have checked, double checked, deleted, recreated the binding sources....all to no avail. I tried the code supplied here but my VB2010 choked on this line
combobox.datasource=?datasource
Also followed jmcilhinney's advice to the letter...it didn't fix my problem either..
Help appreciated greatly...
Firstly, please don't post the same thing three times.
Secondly, if you had the same problem then the same solution would have worked. Obviously there is something different about your situation so please describe your situation FULLY and CLEARLY and then we can address it specifically.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
Firstly, please don't post the same thing three times.
Secondly, if you had the same problem then the same solution would have worked. Obviously there is something different about your situation so please describe your situation FULLY and CLEARLY and then we can address it specifically.
Yea..well the forum kept hanging when I was trying to post.... sat there for several minutes doing nothing... so I closed Chrome, went back and reposted... so that's why it tripple posted...
-
Re: refresh combobox values after updating its datatable and adapter
Situation: 2 forms , Access 2003 database
Combobox on form 1 not showing changed or new records unless I exit debugger and then run it again.
form2 contains datagrid, dataset, tableadapter, binding source, load code, save code, add record code
[Binding source]
Datasource = ProFlow1DataSet
Datamember = orificedata
[Datagrid]
Bindingsource = Proflow1DatSetBindingSource
Load code
Code:
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Save code
Code:
Me.OrificedataTableAdapter.Update(ProFlow1DataSet.orificedata)
If I edit data in the datagrid and click save, the datagrid show the changed value.
BUT if I add a new item to the datagrid I notice the ID [primary key in the .mdb table] shows a negative number rather than a sequential positive number after I click the Add button.
If I close that form and reopen it, the ID number is then sequential as it should be. I have a feeling this may be tied in with the main problem of the combobox on form1 now showing updated values. Here's the code that adds a new record to the datagrid
Code:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Adds Orifice Information to Datagrid by writing to the orificedata table in the db and updating the datagridview
Dim dsNewRow As DataRow
Dim userMsg As String
'Prompt the user to name the new orifice
userMsg = Microsoft.VisualBasic.InputBox("Enter a Name for the ORIFICE", "C&D ProFlow Orifice Data", "Example: Intake-1 or Exhaust-1")
'Do the updating work to the database table
dsNewRow = ProFlow1DataSet.orificedata.NewRow
dsNewRow.Item("diameter") = Me.TextBox3.Text
dsNewRow.Item("area") = Me.TextBox7.Text
dsNewRow.Item("Cd") = Me.TextBox5.Text
dsNewRow.Item("Range") = Me.TextBox8.Text
dsNewRow.Item("Name") = userMsg
ProFlow1DataSet.orificedata.Rows.Add(dsNewRow)
'Update the datagridview with the new data
OrificedataTableAdapter.Update(ProFlow1DataSet)
End Sub
Form 1 has the combobox that is not updating.
[combobox]
datasource = Proflow1DatSetBindingSource
Display member = name
Bindingsource [underneath the form] = Bindingsource = Proflow1DatSetBindingSource
[Proflow1DatSetBindingSource]
Datasource = ProFlow1DataSet
Datamember = orificedata
Form1 load code
Code:
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Ok..that's the layout... I hope I included everything.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
Situation: 2 forms , Access 2003 database
Combobox on form 1 not showing changed or new records unless I exit debugger and then run it again.
form2 contains datagrid, dataset, tableadapter, binding source, load code, save code, add record code
[Binding source]
Datasource = ProFlow1DataSet
Datamember = orificedata
[Datagrid]
Bindingsource = Proflow1DatSetBindingSource
Load code
Code:
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Save code
Code:
Me.OrificedataTableAdapter.Update(ProFlow1DataSet.orificedata)
If I edit data in the datagrid and click save, the datagrid show the changed value.
BUT if I add a new item to the datagrid I notice the ID [primary key in the .mdb table] shows a negative number rather than a sequential positive number after I click the Add button.
If I close that form and reopen it, the ID number is then sequential as it should be. I have a feeling this may be tied in with the main problem of the combobox on form1 now showing updated values. Here's the code that adds a new record to the datagrid
Code:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Adds Orifice Information to Datagrid by writing to the orificedata table in the db and updating the datagridview
Dim dsNewRow As DataRow
Dim userMsg As String
'Prompt the user to name the new orifice
userMsg = Microsoft.VisualBasic.InputBox("Enter a Name for the ORIFICE", "C&D ProFlow Orifice Data", "Example: Intake-1 or Exhaust-1")
'Do the updating work to the database table
dsNewRow = ProFlow1DataSet.orificedata.NewRow
dsNewRow.Item("diameter") = Me.TextBox3.Text
dsNewRow.Item("area") = Me.TextBox7.Text
dsNewRow.Item("Cd") = Me.TextBox5.Text
dsNewRow.Item("Range") = Me.TextBox8.Text
dsNewRow.Item("Name") = userMsg
ProFlow1DataSet.orificedata.Rows.Add(dsNewRow)
'Update the datagridview with the new data
OrificedataTableAdapter.Update(ProFlow1DataSet)
End Sub
Form 1 has the combobox that is not updating.
[combobox]
datasource = Proflow1DatSetBindingSource
Display member = name
Bindingsource [underneath the form] = Bindingsource = Proflow1DatSetBindingSource
[Proflow1DatSetBindingSource]
Datasource = ProFlow1DataSet
Datamember = orificedata
Form1 load code
Code:
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Ok..that's the layout... I hope I included everything.
You don't have a problem at all. You simply have two copies of the data from the database. Changing one of those copies doesn't affect the other. Saving the changes from one of the copies to the data doesn't change the other. If you have a ComboBox bound to a DataTable and you never actually change what's in that DataTable, why would what you see in the ComboBox change?
The contents of your DataTable is representative of what was in the database when you queried it. If the contents of the database changes and you want your DataTable to reflect those changes then you have to query the database again to populate the DataTable again. It's that simple.
Alternatively, don't use two DataTables. If you only use one DataTable on both forms then both forms will inherently reflect the changes made on the other.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
You don't have a problem at all. You simply have two copies of the data from the database. Changing one of those copies doesn't affect the other. Saving the changes from one of the copies to the data doesn't change the other. If you have a ComboBox bound to a DataTable and you never actually change what's in that DataTable, why would what you see in the ComboBox change?
The contents of your DataTable is representative of what was in the database when you queried it. If the contents of the database changes and you want your DataTable to reflect those changes then you have to query the database again to populate the DataTable again. It's that simple.
Alternatively, don't use two DataTables. If you only use one DataTable on both forms then both forms will inherently reflect the changes made on the other.
I"m sure you are correct. However I don't see where the error is. If you could be so kind as to point it out..... I'm shot looking at these screens tonight... Will pick this up tomorrow again..
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
I"m sure you are correct. However I don't see where the error is. If you could be so kind as to point it out..... I'm shot looking at these screens tonight... Will pick this up tomorrow again..
There is no "error'. It's all doing exactly what it should do. If you want to update the data in the ComboBox then you have to query the database to populate the DataTable that it's bound to. You already know how to do that because you're already doing it. You're only doing it when the form first loads though, so the data won't change after that. If you want the data to change later then you have to query the database again later.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
There is no "error'. It's all doing exactly what it should do. If you want to update the data in the ComboBox then you have to query the database to populate the DataTable that it's bound to. You already know how to do that because you're already doing it. You're only doing it when the form first loads though, so the data won't change after that. If you want the data to change later then you have to query the database again later.
I have tried this code ....it doesn't work...
Code:
Private Sub cboFlowRanges_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
End Sub
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
First, why are you filling the DataTable when the user selects a new item in the combobox? By that point, it's too late since the user will only be selecting what is currently in the ComboBox's DataSource.
I think the problem that you're having is that you don't realize that each Form is a different class, so unless you made the DataTable / TableAdapter as global objects (like by making a separate module that declares those objects) or declare the DataTable for one Form and then refer to the Form's DataTable from the second Form, then as jmcilhinney mentioned, you are actually referring to 2 separate objects in your program and therefore have to refresh each separately. I think that you should just declare the DataTable in Form1 and then refer to that from Form2.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
I have tried this code ....it doesn't work...
Code:
Private Sub cboFlowRanges_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
End Sub
That code is going to add all the data from the database to the data you already have every time the user selects something different in the ComboBox. Does that make any sense at all? Firstly, if you're getting new data then logic would dictate that you don't want the old data any more. Where are you getting rid of the old data? Secondly, when do you actually want to refresh the data? Surely not every time the user selects an item in the ComboBox. Put some thought into where you put the code based on what event is raised at the time that you want to perform the action.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
That code is going to add all the data from the database to the data you already have every time the user selects something different in the ComboBox. Does that make any sense at all? Firstly, if you're getting new data then logic would dictate that you don't want the old data any more. Where are you getting rid of the old data? Secondly, when do you actually want to refresh the data? Surely not every time the user selects an item in the ComboBox. Put some thought into where you put the code based on what event is raised at the time that you want to perform the action.
Go back and read your other comment... You said I needed to requery the database again from the combobox.... How else would I do it?
Quote:
If you want to update the data in the ComboBox then you have to query the database to populate the DataTable that it's bound to. You already know how to do that because you're already doing it. You're only doing it when the form first loads though
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
That code is going to add all the data from the database to the data you already have every time the user selects something different in the ComboBox. Does that make any sense at all? Firstly, if you're getting new data then logic would dictate that you don't want the old data any more. Where are you getting rid of the old data? Secondly, when do you actually want to refresh the data? Surely not every time the user selects an item in the ComboBox. Put some thought into where you put the code based on what event is raised at the time that you want to perform the action.
Just take my word for it. The app's use is designed exactly how it has to be to be useful. I have already built this in VBA with Excel and it's been used GLOBALLY for several years... I am trying to redo the app in a stand alone application...
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
Pyth007
First, why are you filling the DataTable when the user selects a new item in the combobox? By that point, it's too late since the user will only be selecting what is currently in the ComboBox's DataSource.
I think the problem that you're having is that you don't realize that each Form is a different class, so unless you made the DataTable / TableAdapter as global objects (like by making a separate module that declares those objects) or declare the DataTable for one Form and then refer to the Form's DataTable from the second Form, then as jmcilhinney mentioned, you are actually referring to 2 separate objects in your program and therefore have to refresh each separately. I think that you should just declare the DataTable in Form1 and then refer to that from Form2.
I didn't know that. I assumed, perhaps wrongly that once a dataset is created that it's globally available to every form. If not, why bother to have it in the DataSource tool bar? Considering that you can drag and drop items from a dataset onto a form I assumed the myriad of adapters, binding sources, et al.. would work by default and point to the correct sources.... BUT HEY... assuming is not usually a great idea :)
I don't know how to make them global objects. Which is easier to declare them global or create a module and make it public?
Also... so what you're sayhing is that on any form I currently attempt to use an existing dataset, that the GUI doesn't use the actual dataset but instead creates a new instance but with the same name? ...
Here's something else that confuses me.. IF the combobox on form one and the dgv on the other form are in fact pointed to different datasets [even though they have the same name] then it would make perfect sense that data from one is not shown in the other... I get that..
BUT, when i exit the debugger and restart it, the same data is displayed in both [if they truly are different] datasets.. WHY? Because both forms use a .fill in the load code. So that means they are both filling from the actual database...correct?
So does it not stand to reason that I should be able to tell the combobox to FILL again via an index changed sub and get all new or changed data from the database table...pulled into both datasets... After all, it works that way on from load...
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Talk about grave digging. This thread is like 6 years old lol.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
Go back and read your other comment... You said I needed to requery the database again from the combobox.... How else would I do it?
I know exactly what I said. I said that you need to requery the database if you want new data. I certainly didn't say that you need to do it "from the combobox", which isn't what you're doing anyway. I also didn't say that you should keep the old data when you got the new data. I assumed that that went without saying. Apparently not.
First, you have to think about WHEN you need to get new data and handle the appropriate event. You certainly do NOT want to get new data every time the user selects an item so obviously the SelectedIndexChanged event handler of the ComboBox is the wrong place for the code. You also need to clear out the old data before getting the new.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
Just take my word for it. The app's use is designed exactly how it has to be to be useful. I have already built this in VBA with Excel and it's been used GLOBALLY for several years... I am trying to redo the app in a stand alone application...
I'll take your word for that. It's completely irrelevant but your word is taken.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
I didn't know that. I assumed, perhaps wrongly that once a dataset is created that it's globally available to every form. If not, why bother to have it in the DataSource tool bar? Considering that you can drag and drop items from a dataset onto a form I assumed the myriad of adapters, binding sources, et al.. would work by default and point to the correct sources.... BUT HEY... assuming is not usually a great idea :)
I don't know how to make them global objects. Which is easier to declare them global or create a module and make it public?
Also... so what you're sayhing is that on any form I currently attempt to use an existing dataset, that the GUI doesn't use the actual dataset but instead creates a new instance but with the same name? ...
Here's something else that confuses me.. IF the combobox on form one and the dgv on the other form are in fact pointed to different datasets [even though they have the same name] then it would make perfect sense that data from one is not shown in the other... I get that..
BUT, when i exit the debugger and restart it, the same data is displayed in both [if they truly are different] datasets.. WHY? Because both forms use a .fill in the load code. So that means they are both filling from the actual database...correct?
So does it not stand to reason that I should be able to tell the combobox to FILL again via an index changed sub and get all new or changed data from the database table...pulled into both datasets... After all, it works that way on from load...
The Data Source is a way for you to easily interact with the database. When I say easily, I mean with very little code or even other effort. For instance, if you drag a table from the Data Sources window, the IDE will create a DataGridView, BindingNavigator, BindingSource, DataSet and TableAdapter as well as generate some code. That's the point.
The typed DataSet generated is a class, just like any other. As such, to be able to use that DataSet you need to create an instance of it, just as would any other class. Don't try to imbue it with any special powers. It's just a class and you use it like any other class.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
I know exactly what I said. I said that you need to requery the database if you want new data. I certainly didn't say that you need to do it "from the combobox", which isn't what you're doing anyway. I also didn't say that you should keep the old data when you got the new data. I assumed that that went without saying. Apparently not.
First, you have to think about WHEN you need to get new data and handle the appropriate event. You certainly do NOT want to get new data every time the user selects an item so obviously the SelectedIndexChanged event handler of the ComboBox is the wrong place for the code. You also need to clear out the old data before getting the new.
If using index changed on the combobox isn't the answer, then SPECIFICALLY what is?
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
The Data Source is a way for you to easily interact with the database. When I say easily, I mean with very little code or even other effort. For instance, if you drag a table from the Data Sources window, the IDE will create a DataGridView, BindingNavigator, BindingSource, DataSet and TableAdapter as well as generate some code. That's the point.
The typed DataSet generated is a class, just like any other. As such, to be able to use that DataSet you need to create an instance of it, just as would any other class. Don't try to imbue it with any special powers. It's just a class and you use it like any other class.
:) It's got it's own special powers and they're not working well for me at the moment.. What are you driving at with your reply? You're suggesting something perhaps?
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
I know exactly what I said. I said that you need to requery the database if you want new data. I certainly didn't say that you need to do it "from the combobox", which isn't what you're doing anyway. I also didn't say that you should keep the old data when you got the new data. I assumed that that went without saying. Apparently not.
First, you have to think about WHEN you need to get new data and handle the appropriate event. You certainly do NOT want to get new data every time the user selects an item so obviously the SelectedIndexChanged event handler of the ComboBox is the wrong place for the code. You also need to clear out the old data before getting the new.
Actually, I do want the user to get all of the data in that combobox, every single time they select it. Old data, new data...doesn't matter I want them to get all of it... There is a reason for this...
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
If using index changed on the combobox isn't the answer, then SPECIFICALLY what is?
It's your application. You tell me. Here's how it works. You ask yourself exactly what happens in the application to prompt the data refresh. You then determine what event is raised or the like when that happens and that tells you where to put the code. I would guess that it's when the second form, i.e. the form that modifies and saves the data, closes but that is based on very limited information. It's your application; you know how you want it to work; you decide.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
Actually, I do want the user to get all of the data in that combobox, every single time they select it. Old data, new data...doesn't matter I want them to get all of it... There is a reason for this...
So, lets' say that you have 10 records in the database to begin with. You populate the ComboBox with those 10 records. The user then adds a new record so you have 11 records in the database. How many items do you want in the ComboBox? Do you really want the original 10 plus the currect 11, i.e. 21 in total, or do you actually just want the current 11 records, as I was saying?
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
:) It's got it's own special powers and they're not working well for me at the moment.. What are you driving at with your reply? You're suggesting something perhaps?
I was suggesting that you seem not to understand how Data Sources and typed DataSets work and you might benefit from a bit of an explanation.
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
It's your application. You tell me. Here's how it works. You ask yourself exactly what happens in the application to prompt the data refresh. You then determine what event is raised or the like when that happens and that tells you where to put the code. I would guess that it's when the second form, i.e. the form that modifies and saves the data, closes but that is based on very limited information. It's your application; you know how you want it to work; you decide.
To me, selecting the combobox is the only logical answer. You click it and it should present the desired data. It's not doing that. So quite frankly if index changed isn't the place to query that database for the latest data... I don't know what is. If I did...the logic dictates I wouldn't need to be here asking.....
If you have a realistic solution, I'm listening. So far other than examining the structure of the binding sources and declaring that I have two different datasets with the suggestion to requery the database... I don't see where you're actually helping me resolve this. Understand something here. I know what I want the combobox to do and why I want it to do it. What I don't know is HOW TO MAKE IT HAPPEN..
-
Re: refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
To me, selecting the combobox is the only logical answer. You click it and it should present the desired data. It's not doing that. So quite frankly if index changed isn't the place to query that database for the latest data... I don't know what is. If I did...the logic dictates I wouldn't need to be here asking.....
If you have a realistic solution, I'm listening. So far other than examining the structure of the binding sources and declaring that I have two different datasets with the suggestion to requery the database... I don't see where you're actually helping me resolve this. Understand something here. I know what I want the combobox to do and why I want it to do it. What I don't know is HOW TO MAKE IT HAPPEN..
You seem determined to assume you're right even though you know that what you're doing doesn't work. Consider this. You open that form and the ComboBox gets populated with 10 items from the database. You press the Tab key until that ComboBox receives focus. You now press the Down arrow key until the last item in the list is selected. That means that the SelectedIndexChanged event of the ComboBox will be raised 10 times. Are you saying that it makes sense to requery the database 10 times during that process?
I certainly hope not. It makes no sense to requery the database at all during that process because you know for a fact that the data in the database is still exactly the same as it was when you started. It only makes sense to requery the database when the data has, or at least may have, changed. What happens in your application when the data changes? I don't know because I'm not there and I've never seen your app and you've never described it in detail. You're sitting there in front of it and wrote it in the first place. If you don't know then who would?
Engage your brain. Like so many people, you seem to think that the only thing that qualifies as help is someone else doing your thinking for you. I won't be doing that.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
I fixed the problem. :)
I was working on the wrong form for a solution. I needed to add code to the form with the datagridview rather than the from that actually contains the combobox.
Code:
Private Sub BtnUpdateOrificeData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUpdateOrificeData.Click
Me.OrificedataTableAdapter.Update(ProFlow1DataSet.orificedata)
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Me.OrificedataTableAdapter.Fill(frmMain.ProFlow1DataSet.orificedata)
MsgBox("Orifice Data Has Been Saved")
End Sub
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
I fixed the problem. :)
I was working on the wrong form for a solution. I needed to add code to the form with the datagridview rather than the from that actually contains the combobox.
Code:
Private Sub BtnUpdateOrificeData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUpdateOrificeData.Click
Me.OrificedataTableAdapter.Update(ProFlow1DataSet.orificedata)
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Me.OrificedataTableAdapter.Fill(frmMain.ProFlow1DataSet.orificedata)
MsgBox("Orifice Data Has Been Saved")
End Sub
You weren't working on the wrong form. You were working with the wrong event, as I said. You could still put the code in the other form and, in fact, you should, but you are now at least invoking the code on the correct event.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
You weren't working on the wrong form. You were working with the wrong event, as I said. You could still put the code in the other form and, in fact, you should, but you are now at least invoking the code on the correct event.
What event is that?
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
The root of the issue that I had stemmed from not knowing how VB handles database communication and structure. I know you're a Microsoft die hard from reading your posts and that's all well and fine. However this isn't my first go around with databases but it is my first go around with VB. Quite frankly the way it does some things causes confusion.
Once the other guy explained how the datasets are not global but instead are form by form entities by default, things began to click.
I have used Excel with ODBC drivers to pull data from Access and Progress databases in the past. I build a lot of reports for human resources, payroll, nursing, etc with excel by pulling data from a Progress backend database with their ODBC drivers.
In my Excel app of similar function I found it very straight forward to connect to, add and modify data using no GUI.. only code.
Now that I have a better understanding of how VB.net does things, I'll go another mile or two.....then stumble, fall down and ask more questions..
Thanks for the help.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
To me, selecting the combobox is the only logical answer. You click it and it should present the desired data.
The event for what you are describing is Enter (or possibly DropDown) not SelectedIndexChanged. The Enter event happens when a control gains focus such as when the user clicks the ComboBox. SelectedIndexChanged event occurs when the user selects one of the items in the ComboBox. But you want all of the items already in the ComboBox before the user makes a selection (otherwise they may complain that the new item isn't listed; they'd have to select an item to get all of the items refreshed and then make their actual selection a second time after the ComboBox has refreshed).
I have created this small program to show the difference. It has a Button (named btnTest1) and a ComboBox (named cboTest) and has a List(Of String) that the ComboBox's DataSource is connected to:
VB.Net Code:
Public Class Start
Public lstItems As New List(Of String)
Private Sub btnTest1_Click(sender As System.Object, e As System.EventArgs) Handles btnTest1.Click
With Me.lstItems
.Add("A")
.Add("B")
.Add("C")
End With
End Sub
Private Sub cboTest1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cboTest1.SelectedIndexChanged
Me.cboTest1.DataSource = Nothing
Me.cboTest1.DataSource = Me.lstItems
End Sub
'Private Sub cboTest1_Enter(sender As Object, e As System.EventArgs) Handles cboTest1.Enter
' Me.cboTest1.DataSource = Nothing
' Me.cboTest1.DataSource = Me.lstItems
'End Sub
Private Sub Start_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.lstItems.Add("Hello")
Me.cboTest1.DataSource = Me.lstItems
End Sub
End Class
When the program runs, the ComboBox will initially just contain the word "Hello". When the button is clicked, the letters "A", "B", and "C" get added to the List. Then one of the ComboBox's events will trigger the List to be reset as its DataSource. Currently I have the SelectedIndexChanged handling the DataSource reset, but to see how the Enter event works, just comment out the SelectedIndexChanged handler and uncomment the Enter handler. Then do these steps to see the difference:
- Run the program and drop-down the ComboBox to see its initial items (eg the word "Hello")
- Click on the Button to add some more items to the List
- Drop-down the ComboBox again. If the Enter event handler is enabled, then you'll see all of the items listed (eg "Hello", "A", "B", and "C"); at this point you can quit. If the SelectedIndexChanged handler is enabled, then it will look like nothing happened and only the word "Hello" will be listed; you'll need to continue with the remaining steps to see the new items in the List for the ComboBox.
- While the ComboBox is in its drop-down state, click on the word "Hello". The ComboBox should close at this point (showing only the editable portion with the drop-down list hidden).
- Drop-down the ComboBox again to see that the DataSource was reset when you selected the word "Hello" in the previous step.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
Pyth007
The event for what you are describing is Enter (or possibly DropDown) not SelectedIndexChanged. The Enter event happens when a control gains focus such as when the user clicks the ComboBox. SelectedIndexChanged event occurs when the user selects one of the items in the ComboBox. But you want all of the items already in the ComboBox before the user makes a selection (otherwise they may complain that the new item isn't listed; they'd have to select an item to get all of the items refreshed and then make their actual selection a second time after the ComboBox has refreshed).
I have created this small program to show the difference. It has a Button (named btnTest1) and a ComboBox (named cboTest) and has a List(Of String) that the ComboBox's DataSource is connected to:
VB.Net Code:
Public Class Start
Public lstItems As New List(Of String)
Private Sub btnTest1_Click(sender As System.Object, e As System.EventArgs) Handles btnTest1.Click
With Me.lstItems
.Add("A")
.Add("B")
.Add("C")
End With
End Sub
Private Sub cboTest1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles cboTest1.SelectedIndexChanged
Me.cboTest1.DataSource = Nothing
Me.cboTest1.DataSource = Me.lstItems
End Sub
'Private Sub cboTest1_Enter(sender As Object, e As System.EventArgs) Handles cboTest1.Enter
' Me.cboTest1.DataSource = Nothing
' Me.cboTest1.DataSource = Me.lstItems
'End Sub
Private Sub Start_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.lstItems.Add("Hello")
Me.cboTest1.DataSource = Me.lstItems
End Sub
End Class
When the program runs, the ComboBox will initially just contain the word "Hello". When the button is clicked, the letters "A", "B", and "C" get added to the List. Then one of the ComboBox's events will trigger the List to be reset as its DataSource. Currently I have the SelectedIndexChanged handling the DataSource reset, but to see how the Enter event works, just comment out the SelectedIndexChanged handler and uncomment the Enter handler. Then do these steps to see the difference:
- Run the program and drop-down the ComboBox to see its initial items (eg the word "Hello")
- Click on the Button to add some more items to the List
- Drop-down the ComboBox again. If the Enter event handler is enabled, then you'll see all of the items listed (eg "Hello", "A", "B", and "C"); at this point you can quit. If the SelectedIndexChanged handler is enabled, then it will look like nothing happened and only the word "Hello" will be listed; you'll need to continue with the remaining steps to see the new items in the List for the ComboBox.
- While the ComboBox is in its drop-down state, click on the word "Hello". The ComboBox should close at this point (showing only the editable portion with the drop-down list hidden).
- Drop-down the ComboBox again to see that the DataSource was reset when you selected the word "Hello" in the previous step.
Thank you for that...greatly appreciated :)
Question... I need to alpha sort that bound combobox. I can't do it in properties because it's bound. Searching for code that does it but not finding it. Also, I expect I would place such code in designer.. is that correct?
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
Thank you for that...greatly appreciated :)
Question... I need to alpha sort that bound combobox. I can't do it in properties because it's bound. Searching for code that does it but not finding it. Also, I expect I would place such code in designer.. is that correct?
Firstly, you might thank Pyth007 for trying, don't use their advice because it's wrong. Secondly, this new question has nothing to do with the topic of this thread so it belongs in a new thread dedicated to that topic.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
Firstly, you might thank Pyth007 for trying, don't use their advice because it's wrong. Secondly, this new question has nothing to do with the topic of this thread so it belongs in a new thread dedicated to that topic.
And you would call this what?????
Quote:
Thank you for that...greatly appreciated
You have YET to answer a direct question I pose. You criticize the app structure yet you don't know how it's used. Then, to top it all off you post a double insult. One to me and one to Pyth007. Seriously...who elected you GOD anway?
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
larrycav
And you would call this what?????
I wasn't saying that you had an obligation to thank someone that you hadn't met. I was saying that thanking someone for trying to help, which you did, is fine but you shouldn't use the information that they provided because it is not correct. I don't know whether you intended to or not but I was warning you not to because it would be detrimental to do so.
Quote:
Originally Posted by
larrycav
You have YET to answer a direct question I pose.
Like so many people who post here and on other forums, you seem to believe that the only acceptable form of help is a turnkey solution that you can basically copy and paste without having to think for yourself. I have helped you but you are apparently unwilling to accept it because it requires you to put some thought and effort into following the direction provided to a solution. I can tell you absolutely that the SelectedIndexChanged event handler of the ComboBox is not the correct place to put code to do what you want to do. I can tell you absolutely that the Enter event handler of the ComboBox is not the correct place to put code to do what you want to do. What I can't do is tell what is the right event to use because you haven't provided enough information for me to do that. I specifically asked for it but you have apparently ignored my request.
Quote:
Originally Posted by jmcilhinney
It only makes sense to requery the database when the data has, or at least may have, changed. What happens in your application when the data changes? I don't know because I'm not there and I've never seen your app and you've never described it in detail. You're sitting there in front of it and wrote it in the first place. If you don't know then who would?
It's that information that will enlighten you - and me - as to what event you need to handle to be able to properly do what you want to do. You haven't provided that information so I can't tell you what event you should handle.
Quote:
Originally Posted by
larrycav
You criticize the app structure yet you don't know how it's used.
You're absolutely right. I don't know how your app works so I can't tell you where you should put your code. If you had provided that information as I requested then I'd be able to provide the direct answer you want. You shouldn't need me to provide that answer though, because you should be able to think for yourself on what your app does when the data changes and what event, if any, is raised at that time. It might even be that it's not about handling an event at all but rather simply doing it after a call to ShowDialog returns. I don't know because you have chosen not to provide the information I need to make that judgement.
Quote:
Originally Posted by
larrycav
Then, to top it all off you post a double insult. One to me and one to Pyth007. Seriously...who elected you GOD anway?
I'm not sure exactly what insults you're referring to. If you're implying that I accused you of not thanking someone when you should have then you have misinterpreted my words. If you're implying that my saying that the advice provided by Pyth007 is wrong is an insult then you're also wrong. To criticise what someone says is not inherently an insult. I don't know anything about Pyth007 so I make no judgements or statements about them as a person or even as a developer. I do know that you should not be handling the Enter event of your ComboBox to do what you want to do so I know that any advice to that effect is wrong. If I say black is white and you say I'm wrong, is that an insult? I certainly hope not.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
I didn't take your comment as an insult per se, but it did rub me wrong in that you just said I was wrong without any follow-up indicating why I was wrong. I tested out the code before I wrote that comment, so I know that it functions the way I thought it would. So in that sense, I wasn't wrong. And I've actually used that handler for a ComboBox in a program that was only one of several front-end applications in case some different station updated the database (actually looking back, I'd probably change it to the DropDown event to prevent an unnecessary hit to the database if a person focused on the ComboBox by tabbing through the form without actually using the ComboBox to make a selection).
If by saying I'm wrong you meant that it is not the ideal solution for the application under discussion, then I'd have to agree with you. Since it sounds like this program is the only thing that is changing the data, then it's better to update the ComboBox's contents when the change is made whether by explicitly programming it in or setting up proper data binding to both controls so that each reflects any changes the other has made.
My example was less as a solution to the problem (esp. since larrycav had mentioned how the problem was solved by moving the code to the update button's click event), but rather more of a way to show the event that he was describing (since it sounded like larrycav was mistaken as to what SelectedIndexChanged meant) as well as to show the distinction between when those events occur.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
I was suggesting that you seem not to understand how Data Sources and typed DataSets work and you might benefit from a bit of an explanation.
Holy hell man you are a troll -- just tell the kid how to refresh a combo box. For such a professional, you don't seem to have common knowledge of a common situation. I came here from Google trying to find the answer and you are just toying with him. If he wanted an explanation, he would have asked -- he wants an answer:
Code:
form1_load(nothing,nothing)
is a simple answer and works -- but it's slow. Anyone else have an idea of just like, a line of code, to refresh the data and ONLY an answer with code?
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
dylanh724
Holy hell man you are a troll
You got me. I do it for kicks. It's got nothing to do with wanting people to use their brains and think for themselves, even if it's against their will.
Quote:
Originally Posted by
dylanh724
If he wanted an explanation, he would have asked -- he wants an answer:
I did want an explanation and I did ask for it - repeatedly - but I never got an answer. I kept saying that we need more information to be able to provide a proper solution and that information was never provided. You get what you pay for.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
jmcilhinney
You got me. I do it for kicks. It's got nothing to do with wanting people to use their brains and think for themselves, even if it's against their will.
I did want an explanation and I did ask for it - repeatedly - but I never got an answer. I kept saying that we need more information to be able to provide a proper solution and that information was never provided. You get what you pay for.
I got it just fine: I understood his problem even in the subject header. It's very clear that he wants to know how to update the values in a bound control after the data is altered. It was obviously very clear or this wouldn't be the top of my Google search for the same issue.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
Quote:
Originally Posted by
dylanh724
I got it just fine: I understood his problem even in the subject header. It's very clear that he wants to know how to update the values in a bound control after the data is altered. It was obviously very clear or this wouldn't be the top of my Google search for the same issue.
And I explained how to do that. In fact, just as in your case, if you think that calling the form's Load even handler directly is going to do it then you obviously already know how to do it too, because you must have code in the Load event handler that already does it. The issue was that someone wanted to know WHERE to put the code and that is not something that anyone can simply pluck out of the air. Where you put code depends on circumstances and if you're not prepared to describe those circumstances then you're not going to get an answer that isn't conjecture, which I'm not prepared to waste my time providing.
-
Re: [RESOLVED] refresh combobox values after updating its datatable and adapter
I realize this thread is old, but I had a similar problem, and I tried all the solutions here as well as .invalidate, .createcontrol, .refresh, .performlayout, and more without success, so I wanted to leave a note as to the solution I found:
I was reading XML data to create a string array, and binding that as the datasource of a combobox. The combobox was not updating when I did this, however. No items or indexes were available, and even if I set the .text property, which was available, my setting was getting strangely overwritten at some indeterminate point after exiting the routine.
In stepping through it multiple times, I eventually realized the combobox was contained on a tabpage that was getting removed when the code started, and later re-added. The data binding was not happening until the tabpage was re-added to the tabcontrol, and it was both raising the selectedindexchanged event at that point, and changing my text.
Hope it helps someone.
In other news...jmcilhinney, you have the patience of a saint. I don't know how you deal with shenanigans like those above without completely losing your biscuit. Good form!