Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to lock a listbox

Status
Not open for further replies.

hinchdog

Programmer
Feb 14, 2001
380
US
is that a way to make a listbox locked,that is, so people can scroll but not select anything? like locking a textbox
 
I think I have a work around in that what I did was that I filled up the listbox but disabled it and set listindex to 0. Then I have a vertical scrollbar next to it and when the user presses the down button I just add 1 to the listindex and when they want to go up I subtract 1. There's a bit of validation required so that you don't go off either edge - but it works!!

Hope it helps....
 
If you don't mind using the Listview found in the Windows Common Controls you can achive the look and feel of a "locked listbox"...
Set following properties of listview:
Code:
.view = lvwReport
.HideColumnHeaders = True
.HideSelection = True
.LabelWrap = False
.FullRowSelect = False
.Gridlines = False
.LabelEdit = lvwManual
Then add two columns to the listview and set the width of the first one to 0. To fill the listview you use something like this:
Code:
With listview1.listitems.Add(,,"")
  .subitems(1) = "
Code:
ListEntry
Code:
"
End With
This looks pretty much as a "locked listbox" I think.

hope this helps
Andreas
 
Sure, you just need to use the SetWindowLong API call to set the Listbox style to LBS_NOSEL.
 
can you show me how to use the API, i'm new to API calls. thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top