Refresh databound combobox

sdoc

New member
Joined
Feb 24, 2007
Messages
4
Programming Experience
5-10
I have a typed dataset with a customers table. here is some code for reference

Private custTA As New MyDS.CustomersTableAdapter
cbxCustomers.DataSource = custTA.GetData()
cbxCustomers.DisplayMember = "CustName"
cbxCustomers.ValueMember = "CustID"

I insert a new customer by calling a stored procedure.
custTA.InsertCustomer( "Name","Address")

Whats the best way to refresh the combobox which is bound to the table?
 
reload the datasource that the combobox is bound to....

i.e. recall the fill command.

I do this when I edit certain parts of my app - I call a model form, and then refill the datatable.
example:
VB.NET:
dim frm as new frmEditCustomerList
frm.showdialog()
me.dscustomer.customer.clear()
me.customerTableAdapter.fill(me.dscustomer.Customer)
 
I insert a new customer by calling a stored procedure.
custTA.InsertCustomer( "Name","Address")

Whats the best way to refresh the combobox which is bound to the table?

If the sproc was your default INSERT command then this would update the combo with no need for a refill:

Dim x as MyDS.CustomersDataTable = DirectCast(cbxCustomers.DataSource, MyDS.CustomersDataTable )
x.AddCustomersRow("Name", "address")
custTA.Update(x) ' upload new row to db, but its already in local so no need to refresh
 
Back
Top