473,320 Members | 1,993 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,320 software developers and data experts.

setting a default value for a combo box...

In my vb.net 2005 project I have a few combo boxes where I want to set a
default value. I am not binding these combo boxes - I am loading the values
directly in code from a dataset.

Obviously the default I am settign will be one of the values from teh drop
down list..

How do you set a default value for a combo box??

Thanks, Brad
Jul 27 '07 #1
2 24853
PS... If I try to set the text property, whatever I type in there is
erased... This is what I thought I would have to do to set a default...

Brad
"Brad Pears" <br***@truenorthloghomes.comwrote in message
news:en**************@TK2MSFTNGP02.phx.gbl...
In my vb.net 2005 project I have a few combo boxes where I want to set a
default value. I am not binding these combo boxes - I am loading the
values directly in code from a dataset.

Obviously the default I am settign will be one of the values from teh drop
down list..

How do you set a default value for a combo box??

Thanks, Brad

Jul 27 '07 #2
Brad,

If the combo box contains strings, you can set the SelectedItem property to
one of the strings to select it.

Or you can set the SelectedIndex property to the zero-based index of the
item to be selected.

Keep in mind that selecting a default value will have the side effect of
causing the SelectedIndexChanged event to fire.

Kerry Moorman
"Brad Pears" wrote:
PS... If I try to set the text property, whatever I type in there is
erased... This is what I thought I would have to do to set a default...

Brad
"Brad Pears" <br***@truenorthloghomes.comwrote in message
news:en**************@TK2MSFTNGP02.phx.gbl...
In my vb.net 2005 project I have a few combo boxes where I want to set a
default value. I am not binding these combo boxes - I am loading the
values directly in code from a dataset.

Obviously the default I am settign will be one of the values from teh drop
down list..

How do you set a default value for a combo box??

Thanks, Brad


Jul 27 '07 #3

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

Similar topics

5
by: Harry Haller | last post by:
<select name="cboPlaces" id="cboPlaces"> <option value="3">Countryside</option> <option value="4">Forest</option> <option value="5">Mountain</option> <option value="6">Desert</option> <option...
2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
6
by: Rick | last post by:
I have a main form called frmDemo with a subform frmStageTrack_Sub. On the subform is a Combo Box CboTermID. The frmDemo is tied to tblDemo and the frmStageTrack_Sub is tied to tblStageTrack. ...
4
by: Torilyn73 | last post by:
I have a combo box set up off a query. I want the default value to be the column heading so I don't have to put a label over it. So far I haven't been able to figure this out. Can anyone tell me if...
1
by: Doug White | last post by:
How do I make a value the default value for a combo box in ASP 3.0? What I have below does NOT work, yet I've seen it in HTML file examples before (and works if I put it in a HTML file by itself, but...
4
by: Doogie | last post by:
I posted this question a few days ago but I think that post is drying up and I still do not have an answer. I need to set a default option for a combo box that is not the first item in that combo...
2
kmartinenko
by: kmartinenko | last post by:
Hi everyone, I have several combo boxes on my form, and while I have designated a column head, I cannot figure out how to default to the column head value. What I really want is for all of my...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
5
by: MNNovice | last post by:
My combo box is pulling data from tblAccounts using its PK (auto number) AccountID but displaying AccountNo (text). Is it possible to set the default value for this combo box to one of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.