473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ComboBox - Changing the selected item

Hi I am having a problem with a combobox the values are generated from a
recordset, I need to beable to change the selected item to the value
specified in a configuration file, I have stored the value as a varible. I
am using the code below but it isn't working any ideas am I using the right
method.
combobox1.selecteditem = getcolvalue(0)

Any help appreciated.

Mike.

Nov 21 '05 #1
4 6646
Hi,
Does the value returned by getcolvalue(0) exist in the combobox list? If it
doesn't, then you will not see the selected item changing.
"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:#Y**************@TK2MSFTNGP09.phx.gbl...
Hi I am having a problem with a combobox the values are generated from a
recordset, I need to beable to change the selected item to the value
specified in a configuration file, I have stored the value as a varible. I
am using the code below but it isn't working any ideas am I using the right
method.
combobox1.selecteditem = getcolvalue(0)

Any help appreciated.

Mike.


Nov 21 '05 #2
Hi

Yest it does the value was created by the listbox and saved to the config.

Mike.

"Shiva" <sh******@online.excite.com> wrote in message
news:ey*************@TK2MSFTNGP11.phx.gbl...
Hi,
Does the value returned by getcolvalue(0) exist in the combobox list? If it doesn't, then you will not see the selected item changing.
"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:#Y**************@TK2MSFTNGP09.phx.gbl...
Hi I am having a problem with a combobox the values are generated from a
recordset, I need to beable to change the selected item to the value
specified in a configuration file, I have stored the value as a varible. I
am using the code below but it isn't working any ideas am I using the right method.
combobox1.selecteditem = getcolvalue(0)

Any help appreciated.

Mike.



Nov 21 '05 #3
Hi,
Just to try an alternative way, have the following instead of using
SelectedText:

combobox1.SelectedIndex = combobox1.FindStringExact(getcolvalue(0))

If the return value of "combobox1.FindStringExact(getcolvalue(0))" is -1
then getcolvalue(0) is returning something that doesn't exist in the combo
list.

"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:ez*************@TK2MSFTNGP09.phx.gbl...
Hi

Yest it does the value was created by the listbox and saved to the config.

Mike.

"Shiva" <sh******@online.excite.com> wrote in message
news:ey*************@TK2MSFTNGP11.phx.gbl...
Hi,
Does the value returned by getcolvalue(0) exist in the combobox list? If it doesn't, then you will not see the selected item changing.
"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:#Y**************@TK2MSFTNGP09.phx.gbl...
Hi I am having a problem with a combobox the values are generated from a
recordset, I need to beable to change the selected item to the value
specified in a configuration file, I have stored the value as a varible. I
am using the code below but it isn't working any ideas am I using the right method.
combobox1.selecteditem = getcolvalue(0)

Any help appreciated.

Mike.




Nov 21 '05 #4
Hi Shiva

Yes that worked, after a bit of playing about I think the first method was
not working because of the way I was pulling the information from the
database, the selectitem method was not returning a string value(well thats
what it said when I tried writing the selecteditem to the debug window)!.

Thanks for all your help.

Mike.
"Shiva" <sh******@online.excite.com> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
Hi,
Just to try an alternative way, have the following instead of using
SelectedText:

combobox1.SelectedIndex = combobox1.FindStringExact(getcolvalue(0))

If the return value of "combobox1.FindStringExact(getcolvalue(0))" is -1
then getcolvalue(0) is returning something that doesn't exist in the combo
list.

"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:ez*************@TK2MSFTNGP09.phx.gbl...
Hi

Yest it does the value was created by the listbox and saved to the config.

Mike.

"Shiva" <sh******@online.excite.com> wrote in message
news:ey*************@TK2MSFTNGP11.phx.gbl...
Hi,
Does the value returned by getcolvalue(0) exist in the combobox list? If

it
doesn't, then you will not see the selected item changing.
"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:#Y**************@TK2MSFTNGP09.phx.gbl...
Hi I am having a problem with a combobox the values are generated from a
recordset, I need to beable to change the selected item to the value
specified in a configuration file, I have stored the value as a varible. I am using the code below but it isn't working any ideas am I using the

right
method.
combobox1.selecteditem = getcolvalue(0)

Any help appreciated.

Mike.





Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Beeeeeeeeeeeeves | last post by:
I have an ownerdrawn combo box which I am drawing with an image and some text, this is all working beautifully apart from the difference in the Brush I have to draw the background and the text with...
2
by: blue_nirvana | last post by:
I use a AddHandler statement in the load event of a form to assoicate a routine with a combobox. When I populate the form, I select the approiate value from the combobox by using...
6
by: Doug Bell | last post by:
Hi I have a datagrid with a combo box, I need to populate the combo with data dependant on the record value. eg for record 1, field Warehouse = 2R so combo would allow selection of locations...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
3
by: Magnus | last post by:
Im using a set combobox (ComboBox1) to provide a selection of records from a database table. I have a typed dataset (DataSet1) that contains the typed datatable (DataTable1) that the combobox is...
19
by: active | last post by:
I'm using a ComboBox to display objects of a class I've defined, say CQQ. Works great except somehow I occasionally set an Item to a String object instead of an object of type CQQ. It looks...
1
by: Andrus | last post by:
I need to enter null value from combobox to business object property. My combobox datasource does not contain ValueMember with null value. So I tried to create combobox which stores null to bound...
11
Frinavale
by: Frinavale | last post by:
This question is going to sound a little crazy but.........How do you set the selected item in a ComboBox? I am populating a ComboBox with a bunch of instances of a custom private class: For...
2
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.