ADezii's method using
AddItem works if you want to do something such as loading the available printers each time a form cranks up, but if you have a cbo with a list of vegetables, and after tasting broccoli you just
have to add it to the list, it won't do! As
NeoPa has so elegantly put it, a table/query based combobox is really the only sane way to go in this situation! It not only allows items to be
added to the combobox which will carry over into future sessions, it allows items to be
removed from the control as well!
A while back I did write a hack for adding items
permanently to a combobox, and can probably find a copy for you (although it may be tomorrow before I get around to finding it; it's on a "retired" PC and I'll have to dig it out) if you absolutely
have to go this route, but it's convoluted and probably more trouble than it's worth! It involves
- Opening a second, dummy, form, passing it the new item using OpenArgs
- Closing the first form
- In the second form, opening the first form in Design Mode
- Adding the item to the cobobox
- Closing the first form
- Closing the second form
- Re-opening the first form, with the new item in the cbo
As I said, it's not pretty! Let me know; I'll try to locate it! But give some thought to using a table/query based combobox!
Welcome to TheScripts!
Linq
;0)>