Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 27th, 2005, 3:17 PM   #1
cloud-
Hobbyist Programmer
 
Join Date: Jan 2005
Posts: 110
Rep Power: 4 cloud- is on a distinguished road
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 ^^;;
cloud- is offline   Reply With Quote
Old May 27th, 2005, 3:51 PM   #2
w00dy
Newbie
 
Join Date: May 2005
Location: UK
Posts: 8
Rep Power: 0 w00dy is on a distinguished road
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
w00dy is offline   Reply With Quote
Old May 27th, 2005, 4:15 PM   #3
cloud-
Hobbyist Programmer
 
Join Date: Jan 2005
Posts: 110
Rep Power: 4 cloud- is on a distinguished road
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
cloud- is offline   Reply With Quote
Old May 27th, 2005, 4:24 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Pretty simple, really:
Private Sub Form_Load ()
    ComboBox1.AddItem "Normal"
End Sub
... I think.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 27th, 2005, 5:39 PM   #5
w00dy
Newbie
 
Join Date: May 2005
Location: UK
Posts: 8
Rep Power: 0 w00dy is on a distinguished road
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
w00dy is offline   Reply With Quote
Old May 27th, 2005, 6:30 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 28th, 2005, 3:44 AM   #7
cloud-
Hobbyist Programmer
 
Join Date: Jan 2005
Posts: 110
Rep Power: 4 cloud- is on a distinguished road
that just adds the item
i still cant see any text in the combo when the form loads.


ideas?
thanks
cloud- is offline   Reply With Quote
Old May 28th, 2005, 4:43 AM   #8
w00dy
Newbie
 
Join Date: May 2005
Location: UK
Posts: 8
Rep Power: 0 w00dy is on a distinguished road
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.
w00dy is offline   Reply With Quote
Old May 28th, 2005, 5:12 AM   #9
cloud-
Hobbyist Programmer
 
Join Date: Jan 2005
Posts: 110
Rep Power: 4 cloud- is on a distinguished road
ok, ill try that
+thanks
cloud- is offline   Reply With Quote
Old May 28th, 2005, 7:09 AM   #10
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Ah... I gotcha. Set ListIndex to something other than -1:
ComboBox1.ListIndex = 0
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC