windows - How do I rebind a combobox in winforms? -


I have a Winforms application and a combo box has been set to load the data when the form loads is. Shows data in Cambodia right

Then after a user clicks on a button I want to create a new DataTable and want to assign to the dotset as a dataset for the contour.

The problem is that after setting the data source, new dataable does not change items in the combobox. Here's the code I'm using.

  dlCustomer.DataSource = Nothing dlCustomer.DataSource = dtCustomers dlCustomer.DisplayMember = "name" dlCustomer.Refresh ()  

Does anyone know that How do I allocate data sources for this to display the correct data for the second time in the combo box?

It should work, at least one quick test I have thrown together here is the code; It expects a form with a combo box and a button:

  public class form 1 private DTO such as private DTO datatelas Private Sub Startups () dtOne = "New Tablet ") With dtOne. Add columns ("text", gettip (string)). Add columns. ("Value", Gatept (integer)) DTTO = Finish with new datatelle ("Tablet two") with DTTO Columns Add ("Text", GetType (String)). Col.Ed ("Value", GateTip (integer) with the new line in the form of the end row as the DataRow integer = 0 to 2NewRah = dtOne.NewRow newRow.ItemArray = (New object () {Spline (Index), index}) dtOne.Rows.Add (newRow) for the next index as integer = 2 to 0 stage-1 monarchy = dtTwo.NewRow newRow.ItemArray = (new object () {SpellIt (index ), Index}) dtTwo.Rows.Add (newRow) next dtOne.AcceptChanges () dtTwo.AcceptChanges () End Sub Private Sharing Function Select SpellIt (ByVal int as integer) string As Case In Case: 0: "Zero" Case 1: Return "A" Case 2: Reject New Logic OUTRANGE APPLICATION ("Belle!") Select End End Expiration Function Private Sub Form 1_load (Sub-System Sender.Object, as the system, in the form of e-mail and system.AventRG) MyBase.Load InitializeTables () Me.Label1.DataBindings.Add ("Text", ComboBox1, "SelectedValue") Me.ComboBox1.DataSource = DtOne Me.ComboBox1.DisplayMember = "Text" Me.ComboBox1.ValueMember = "Value" End Sub Private Sub Button 1_Click (ByVal Sender as System.Object, ByVal E. System.EventArgs) button handle 1. Click Me.Combo Box 1. Databinds Clear () Me.ComboBox1.DataSource = Nothing Me Combo box 1 Datasource = DTTO m Combo box 1 Displaymile = "text" m Combo box 1 Value = "value" and end and class  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -