I have a combobox which is databound to a dataset. When I call addnew it clears the selection but doesnt add my text. I end up a the original items in the list but an extra blank entry that is linked to the new entry.
THis is because the combo box is strictly being used as a selector, not dataentry, you would have to do some logic in your save button/method
Dim CM as currencymanager = ctype(me.bindingcontext(datasource,"tablename"),currencymanager)
dim DRV as datarowview = ctype(cm.current,datarowview) drv.item("PhoneType") = combobox1.text then turnaround and add a new Datarow to the datasource of the combobox and update the database.
then call endcurrentedit on the CM and then do your update (which you will also have to call refresh on the datasource of the combobox
Hope this helps. Personally For combo boxes and such I don't allow editing, people will add all kinds of crap and the combobox will get long as f#$# People are so lazy they will start typing in thier own thing instead of looking.
My first post wasnt very clear - hopefully this will be a bit better:
I have a combobox and a text box. They are both databound to different fields of a datatable. The combobox contains a list of telephone number descriptions eg. Home, Mobile, Work. When an item is selected the appropriate number is displayed in the text box.
When I call AddNew the textbox and combobox clear as expected. The problem is that the description I type into the combobox is lost and replaced with a blank item in the combobox. Incidentaly, the blank entry when selected does correspond to the telephone number entered. No matter what I do I cant edit the text in the combobox!!
How do add an item to a databound combobox
PeterNL
Dim CM as currencymanager = ctype(me.bindingcontext(datasource,"tablename"),currencymanager)
dim DRV as datarowview = ctype(cm.current,datarowview)
drv.item("PhoneType") = combobox1.text
then turnaround and add a new Datarow to the datasource of the combobox and update the database.
then call endcurrentedit on the CM and then do your update (which you will also have to call refresh on the datasource of the combobox
Hope this helps. Personally For combo boxes and such I don't allow editing, people will add all kinds of crap and the combobox will get long as f#$# People are so lazy they will start typing in thier own thing instead of looking.
chmur
or addnew to the combobox
James Woodall
richhudec
I have a combobox and a text box. They are both databound to different fields of a datatable. The combobox contains a list of telephone number descriptions eg. Home, Mobile, Work. When an item is selected the appropriate number is displayed in the text box.
When I call AddNew the textbox and combobox clear as expected. The problem is that the description I type into the combobox is lost and replaced with a blank item in the combobox. Incidentaly, the blank entry when selected does correspond to the telephone number entered. No matter what I do I cant edit the text in the combobox!!
I sure I am missing a simple trick here,
Any ideas,
Danny