473,748 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Silly combo box question

Hi,

I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.

Thanks,
Adam
May 6 '06 #1
6 1248
"Adam Honek" <Ad*******@Webm aster2001.frees erve.co.uk> schrieb:
I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.


Set the 'SelectedIndex' property to 0. Setting it to -1 causes no item to
be selected, which is indicated by the blank combobox.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 6 '06 #2
Adam,

The first is 0 as most things that are derived from classic VB.

If you want an empty box by not binded data than you can use -1.

I hope this helps,

Cor

"Adam Honek" <Ad*******@Webm aster2001.frees erve.co.uk> schreef in bericht
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi,

I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.

Thanks,
Adam

May 6 '06 #3
Misreaded your answer therefore I did it again.

Sorry

Cor

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schreef in bericht
news:%2******** *******@TK2MSFT NGP04.phx.gbl.. .
"Adam Honek" <Ad*******@Webm aster2001.frees erve.co.uk> schrieb:
I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.


Set the 'SelectedIndex' property to 0. Setting it to -1 causes no item to
be selected, which is indicated by the blank combobox.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 6 '06 #4
Thanks guys, 0 it is and works like a charm.

Adam

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Adam,

The first is 0 as most things that are derived from classic VB.

If you want an empty box by not binded data than you can use -1.

I hope this helps,

Cor

"Adam Honek" <Ad*******@Webm aster2001.frees erve.co.uk> schreef in bericht
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi,

I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.

Thanks,
Adam


May 6 '06 #5
> Adam,

The first is 0 as most things that are derived from classic VB.

If you want an empty box by not binded data than you can use -1.


Unless you are talking Dotnet 1.x and currently have a value selected. In
that case, you need to set it to -1 twice (or sometimes 3 times). Actually,
I think the implementation in 2.0 sets the selectedindex to 0 then -1 if
you try to set it to -1 when it is currently > 0, which effectively means
that unselecting a value will cause a value to be selected temporarily and
then unselected. This to me is more silly than the original question which
has already been answered.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
May 8 '06 #6
kamle_b
5 New Member
Where can I find SelectedIndex property? in Access combo box, right click and properties, because i couldnt find there? or in VB?
May 10 '06 #7

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

Similar topics

3
2012
by: NB | last post by:
Let's say in the product table I have around 50,000 products (well, infact it has now about 2000 only, but it's growing very fast, hence the question here) In the order form, users will select the product for the order lines. They want to see the entire list of available products. You can't handle the combo the way you've heard: limiting rowsource until first few characters entered, because - the product primary key is an autonumber
3
1666
by: Marcus Canales | last post by:
Hello all, Here is my situation. I have a combo box on a form. The combo box is linked to a qry (qryCustomers) and the form is linked to tblOrders. The way I currently use the combo box is to place the CustID number in to the table tblOrders. My question arises in that I would like to know if there is a way to initiate a new record (in my customers table) when a user types a value in the combo box that isn't in the list. Let me...
8
18392
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". The values in the dropdown are loaded in the correct order, but the initial value is not the first row of the dropdown as I expected. The field "CategoryName" is not the primary key for the table -- the PK is
2
1310
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the username - but also determine the UserID from what was selected (using DisplayName from the combo box?? I can populate the combo box without problems - BUT the user sees "System.object" in each item of the combobox not the username ***here is my clas...
9
6761
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the second combo to change depending on what values the user selects in the first box, it's just that every time the user changes the first combobox, the second combobox FOR EVERY RECORD goes blank.
1
2574
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box has 4 possible answers to a question. Each of the 4 possible answers is also assigned a value: answer 1 is worth 1 point, answer 2 is worth 2 points.... What I need to do now is add togethor the points of all the combo boxes. So far I have given...
5
3234
by: Bface | last post by:
Here are the other 2 questions I have. I forgot to mention I am on Access 2003/Windows XP. The second and third question I have is on Combo box. Can a combo box be used to access several documents on the network drive (U) or any other location? For example from the drop down list there are 3 options. Weekly figures Monthly figures Quarter figures Each one of these would open the related word or excel document.
2
3144
by: Sid | last post by:
I need some help in setting up Access combo box. I am using three comboboxes in my form. Comb Box 1, Combo Box 2, Combo Box 3. The row source for each of the combo box is a seperate table. Table 1 acts as row source for Combo Box 1 Table 2 acts as row source for Combo Box 2 However for combobox 3, I was trying to use 4 different tables as row source. I am trying to set up a criteria such that row source for comb
2
7047
by: biganthony via AccessMonster.com | last post by:
Hi, I decided to install Office 2003 Service Pack 3 on my home computer to test (in full knowledge that there may be some issues with it). After installation, I have noticed that with a small database I wrote for home, the combo boxes and listboxes no longer display the bound column. For example, on a form I have a combo box based on a table called 'names'. The two columns in the combo box are ID and Surname. The combo box and list box...
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.