R
roger.breton
Guest
I have a ComboBox in my application which, some users complain, "freezes", so I'm looking for alternative ways to implement it. Originally, it was bound to a specific column from a Data Table, SQL DataSource > Dataset. In my new approach, I experimented with these instructions to populate the ComBox from my SQL database :
Dim CodesList = From row In Me.DataSet.CodeTable.AsEnumerable()
Select row.Field(Of String)("ItemCode")
cboItemCodes.Items.AddRange(CodesList.ToArray())
This part works like a charm. All the data shows up the ComboBox perfect. But that's as far as it goes. When I try to Add or Drop or Modify elements out of the ComboBox, it goes haywire. This is the code I use to Add elements :
cboItemCodes.BeginUpdate()
cboItemCodes.Items.Add(tbItemCode.Text)
cboItemCodes.EndUpdate()
cboItemCodes.Update() ' I did not have the "Update()" at first but found the new elements were not showing
This is the code I use to Remove elements:
cboItemCodes.BeginUpdate()
cboItemCodes.Items.Remove(tbItemCode.Text)
cboItemCodes.EndUpdate()
cboItemCodes.Update() ' I did not have the "Update()" at first
And this is the code I use to Modify elements:
cboItemCodes.BeginUpdate()
cboItemCodes.Items.Remove(tb_OLDItemCode.Text)
cboItemCodes.Items.Add(tb_NewItemCode.Text)
cboItemCodes.EndUpdate()
I don't see what I'm missing. The worst is the 'Modify' instructions because I end up with twice as many items in ComboBox as I started with after its execution?
I made sure the code works by counting the number of items in the ComboBox BEFORE and AFTER each operation and that part is flawless. What does not seem work is the refresh of the ComboBox items.
Any help is appreciated.
Continue reading...
Dim CodesList = From row In Me.DataSet.CodeTable.AsEnumerable()
Select row.Field(Of String)("ItemCode")
cboItemCodes.Items.AddRange(CodesList.ToArray())
This part works like a charm. All the data shows up the ComboBox perfect. But that's as far as it goes. When I try to Add or Drop or Modify elements out of the ComboBox, it goes haywire. This is the code I use to Add elements :
cboItemCodes.BeginUpdate()
cboItemCodes.Items.Add(tbItemCode.Text)
cboItemCodes.EndUpdate()
cboItemCodes.Update() ' I did not have the "Update()" at first but found the new elements were not showing
This is the code I use to Remove elements:
cboItemCodes.BeginUpdate()
cboItemCodes.Items.Remove(tbItemCode.Text)
cboItemCodes.EndUpdate()
cboItemCodes.Update() ' I did not have the "Update()" at first
And this is the code I use to Modify elements:
cboItemCodes.BeginUpdate()
cboItemCodes.Items.Remove(tb_OLDItemCode.Text)
cboItemCodes.Items.Add(tb_NewItemCode.Text)
cboItemCodes.EndUpdate()
I don't see what I'm missing. The worst is the 'Modify' instructions because I end up with twice as many items in ComboBox as I started with after its execution?
I made sure the code works by counting the number of items in the ComboBox BEFORE and AFTER each operation and that part is flawless. What does not seem work is the refresh of the ComboBox items.
Any help is appreciated.
Continue reading...