Link to home
Start Free TrialLog in
Avatar of RuschWEB
RuschWEB

asked on

ComboBox Issue

I want a ComboBox that is (*.)Locked but I still want entries to be selectable. In other words, I want entries in the pop-down list to be selectable, but I don't want the user to be able to enter anything manually. Is there a property that I'm missing, or is there any other way around this?
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Put the style of the Combobox to "2  - Dropdown list"

The user can choose a possibility, but can't enter data in combobox
Avatar of RuschWEB
RuschWEB

ASKER

but then i can't put anything into myself even..
e.g.

MenuForm.TimeSlotChoice.Text = WordsLang(1)

..would not work. :\ because style 2 gives the combobox a read-only attribute.. :\ which i can't have.. is there a way i can change the style temporarily throughout the program?
i.e.
MenuForm.TimeSlotChoice.Style = 0
MenuForm.TimeSlotChoice.Text = WordsLang(1)
MenuForm.TimeSlotChoice.Style = 2

..or something like that?
You can add it with code

TimeSlotChoice.additem wordslang(1)

But I don't want to add it to the list as an Item, i just want the Caption of it to become WordsLang(1) in this case.
Know I can't follow any more....

You don't want the user to give the ability to enter data in the combobox. That's done by putting the liststyle to 2

You don't want to add something to the list. Is it the purpose to set the list automatically to the text you give (in this case wordslang(1), beacause that word is already in the list)... if that's what you mean then you have to do

TimeSlotChoice.listindex = 0
while timeslotchoice.listindex < timeslotchoice.listcount -1and timeslotchoice.list <> wordslang(1) then
   timeslotchoice.listindex = timeslotchoice.listindex +  1
wend

If that isn't the meaning, try to explain it better.
ASKER CERTIFIED SOLUTION
Avatar of sridhar12345
sridhar12345

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, sridhar12345 - thank you very much for your help. That solved my problem.

Private Sub TimeSlotChoice_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub

May you live long and prosperous.. :P
Well, before I loose my last points I just wanna ask..
I have an error handler that looks like this..

On Error GoTo ErrorHandler

ErrorHandler:
Select Case Err
Case 7 'out of memory
    tmp = MsgBox(WordsLang(80), vbCritical, WordsLang(85))
    Resume
Case 61 'harddisk full
    tmp = MsgBox(WordsLang(81), vbCritical, WordsLang(85))
    Close All
    End
Case 71 'disk not ready
    tmp = MsgBox(WordsLang(82), vbCritical, WordsLang(85))
    Resume
Case 72 'disk damaged
    tmp = MsgBox(WordsLang(83), vbCritical, WordsLang(85))
    Resume
Case 75 'path/file access error
    tmp = MsgBox(WordsLang(84), vbCritical, WordsLang(85))
    Close All
    End
Else
    tmp = MsgBox(WordsLang(87), vbCritical, WordsLang(85))
    Close All
    End
End Select

Where do I put the label, and where do I put the 'On Error' statement? In a sub somewhere?
on error: under your private/public sub declaration
errorhandler: just above end sub

Private Sub TimeSlotChoice_KeyPress(KeyAscii As Integer)
On Error GoTo ErrorHandler
   KeyAscii = 0
   exit sub
ErrorHandler:
Select Case Err
Case 7 'out of memory
   tmp = MsgBox(WordsLang(80), vbCritical, WordsLang(85))
   Resume
Case 61 'harddisk full
   tmp = MsgBox(WordsLang(81), vbCritical, WordsLang(85))
   Close All
   End
Case 71 'disk not ready
   tmp = MsgBox(WordsLang(82), vbCritical, WordsLang(85))
   Resume
Case 72 'disk damaged
   tmp = MsgBox(WordsLang(83), vbCritical, WordsLang(85))
   Resume
Case 75 'path/file access error
   tmp = MsgBox(WordsLang(84), vbCritical, WordsLang(85))
   Close All
   End
Else
   tmp = MsgBox(WordsLang(87), vbCritical, WordsLang(85))
   Close All
   End
End Select
End Sub
but if i do that, wont it run the "case else" part when i change something in Private Sub TimeSlotChoice_KeyPress(KeyAscii As Integer)?
No, as long as there is no error, your error handler won't start