|
-
Sep 28th, 2000, 03:42 PM
#1
Thread Starter
Lively Member
When the form loads values are loaded into a combobox and a default value is selected from the list.
cbox.seltext = "Illness Self"
But when loading the default value into the combobox, the combobox's ListIndex property doesn't get updated to reflect "Illness Self" as being selected. Even though "Illness Self" is set by the SelText property the ListIndex still shows as -1 not 14 which would be the ListIndex for "Illness Self".
How can I update the ListIndex property when setting a default value for the combobox? It's got to be something easy.
-
Sep 28th, 2000, 04:17 PM
#2
Lively Member
Use the TopIndex property - this shows the correct value for selected item.
C/C++,Delphi, VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
I love deadlines. I like the whooshing sound they make as they fly by.
—Douglas Adams
-
Sep 28th, 2000, 04:18 PM
#3
You can use the Text property to set the text to what you want, which will also highlight the word if it is located in the Combobox.
Code:
cbox.Text = "Illness Self"
-
Sep 28th, 2000, 05:34 PM
#4
Thread Starter
Lively Member
Hitcgar,
How do I use the TopIndex property?
Matthew,
Setting the text property doesn't set the ListIndex to the item that I would set the text to. I need the ListIndex property to reflect the item that is loaded as the default.
I load the selections from a recordset and set the itemdata property for each item to the primary key id from each record in the set. When adding records to the database I need to access the itemdata property to retrieve the primary key that will be added to the database for the record being added. Illness Self is supposed to be the default value. But when set as the default and I don't touch the combobox I get an error "Invalid property array index" because the ListIndex of the combobox is still set at -1 meaning nothing is selected. I can't retrieve the itemdata property value without a listindex value greater that -1.
-
Sep 29th, 2000, 08:03 AM
#5
Thread Starter
Lively Member
I figured it out.
I used the list array and searched for the value and set the listindex.
Code:
For i = 0 To cboReason.ListCount - 1
If cboReason.List(i) = "Illness Self" Then
cboReason.ListIndex = i
End If
Next i
-
Sep 29th, 2000, 12:08 PM
#6
Lively Member
With the TopIndex property you can set the topmost item in the combo to the value you want
ex.
Code:
cb.TopIndex = cb.TopIndex + 5
cb.ListIndex = cb.TopIndex
- causes the list items to scroll 5 items down
But this is only useful for standard combos (not dropdown) and listboxes.
C/C++,Delphi, VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
I love deadlines. I like the whooshing sound they make as they fly by.
—Douglas Adams
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|