wsyeager Posted April 14, 2003 Posted April 14, 2003 I'm getting the following error when trying to set a datasource property to a listbox: "Item collection can't be modified if the Datasource property is set". I want to add a default item to the listbox after the data is loaded, but I get the above msg: Here is my code: cboCustomerID.DataSource = DsCustomerID1.tblCustomerID cboCustomerID.ValueMember = DsCustomerID1.tblCustomerID.Columns("CUSTOMER_ID").ToString cboCustomerID.DisplayMember = DsCustomerID1.tblCustomerID.Columns("CUSTOMER_ID").ToString cboCustomerID.Items.Insert(0, "ALL") Does anyone know how I can add a default item to the listbox? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Negative0 Posted April 14, 2003 Posted April 14, 2003 Simple Answer: Don't use the datasource What I would do, would be loop through your DataSource and add each item using the combobox.items.add function. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.