[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Read-Only Combo Box

Posted on 2002-05-03
7
Medium Priority
?
167 Views
Last Modified: 2010-05-02
How can I make a combo box read only?
0
Comment
Question by:sharon_brindley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:HobbitHouse
ID: 6988222
under properties, make "enabled" False.  This will work for text boxes, list boxes, combo boxes, bread boxes, safety deposit boxes, post office boxes, etc.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 6988249
-set the style to 2-Dropdown list

OR

-set keyascii to 0 into the keypress event
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6988253
readonly combobox:
* either some API (i don't know it...)
* or some vb, which in  the Change and Click event set's the .Listindex value back to the value you want.

CHeers
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6988258
* and of course, you can try to use the .Locked = true property, which will enable the user to see all the values (dropdown), but not choose by clicking or using keyboard...

CHeers
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6988844
If you want full functionality without allowing change:

1) Since the text portion is "useless", as pointed out above, the style should be set to 2-dropdownlist.  Also, the key presses should be disabled:
Private Sub cboXXX_KeyPress(Index As Integer, KeyAscii As Integer)
   KeyAscii = 0
End Sub

2) Since you don't want the user to change the list selection, but could still want to view the choices, you'll need to save the initial state and reset it any time the user inadvertently clicks on a different selection.  To do that, you'll need two code changes:

Private Sub Form_Load()
  Combo1.AddItem "first entry"
  Combo1.AddItem "second entry"
  Combo1.AddItem "third entry"
  Combo1.Tag = "1" ' give an initial value
  Combo1_Click ' set it
End Sub

Private Sub Combo1_Click()
  ' reset it any time the user changes it
  Combo1.ListIndex = Val(Combo1.Tag)
End Sub

Private Sub Combo1_GotFocus()
  ' capture the current setting any time the user goes to it
  Combo1.Tag = CStr(Combo1.ListIndex)
End Sub
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6988850
On further review, angelIII's idea of locked seems to be better.  The difference is that the user cannot click on the dropdown list to close it.
0
 

Author Comment

by:sharon_brindley
ID: 6993351
Setting the style to 2-Dropdown is exactly what I wanted. Setting enabled=false, or locked=true are not suitable as they do not allow the user to select a list item. I actually want full functionality without the user being able to change the items or add more.
Thanks
Sharon
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question