![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
anoying problem with a combo box
hi this is stupid question but i couldnt figure it out..
when i chnge the property of a combo box so that it is a dropdown listbox how do i get a list item to start off ...i mean... when the form loads the combo face is blank i want to add an item to the face.. i know im crap at explaining but if u understand please help ![]() thanks ^^;; |
|
|
|
|
|
#2 |
|
Newbie
Join Date: May 2005
Location: UK
Posts: 8
Rep Power: 0
![]() |
Hi Cloud ~ Do you mean how to add items to the list & then execute the code for whichever one is selected?
Please give me an idea how you are learning, from a book, some other form of help, or what. I may be able to send you some sample code w00dy |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
hey
well i have a combo box..and it worked when it was a normal combo box with this code: Private Sub Form_Load() Combo1.Text = "Normal" End Sub but then i decided i didnt want the combo to be edited (as it would make some other stuff go wrong) so i changed it to a combo list type (number 2 in the styles for combobox) so this doesnt have a textbox i need to make the text "Normal" be displayed in the combo when the form loads. normal is already in the list i know how to add items but currently when the form loads the combo starts off blank untill it is changed know how i can set an item in the list to be displayed. thanks for the help ![]() |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Pretty simple, really:
Private Sub Form_Load ()
ComboBox1.AddItem "Normal"
End Sub |
|
|
|
|
|
#5 |
|
Newbie
Join Date: May 2005
Location: UK
Posts: 8
Rep Power: 0
![]() |
looks right to me, Ooble
I haven't actually used a combo box for a while and I remember now, I had the same problem. Being pretty much a beginner, I didn't think of this solution, but solved the problem by using style 0, and writing a function that would have (in this case) defaulted the combo text to 'Normal' if anything other than one of the list items was entered. My humble efforts are full of this longwinded stuff, I'll have to get round to tidying up one day. w00dy |
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I think everyone does the same thing - it's part of the reason I never just re-use code modules I wrote over three months ago without rewriting half of the module first.
|
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
that just adds the item
i still cant see any text in the combo when the form loads. ![]() ideas? thanks |
|
|
|
|
|
#8 |
|
Newbie
Join Date: May 2005
Location: UK
Posts: 8
Rep Power: 0
![]() |
Hi Cloud ~ Going back to your first post in this thread, it was NOT a stupid question. I suspect vast numbers of people have struggled with this one, including me, as I already admitted. The books I have say thats just the way comboBox is, and there is no property setting that will change it, if you're determined to use a combo in this case, the only way I can see is to use style 0 and write an error routine to negate any attempt to edit the list.
|
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
ok, ill try that
![]() +thanks |
|
|
|
|
|
#10 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Ah... I gotcha. Set ListIndex to something other than -1:
ComboBox1.ListIndex = 0 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|