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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable List Box Scroll Bar

Status
Not open for further replies.

Tommy408

Programmer
Apr 30, 2006
53
US
How can I disable the list box scroll bar through VB? There are scrollbars property for text boxes but I don't see any for List Box.
 
What are you trying to do? If you have fewer values then the size of the listbox you do not have a scrollbar. If you have more you get a scrollbar. So what would you do with a listbox that shows some of the values with no means to get to the other?
 
Yup, that's what I'm trying to do. I have a list of values, and I want to get rid of the scroll bar and ofcourse I won't be able to see the other values. I'd disable this scroll bar on an event if I can set it on/off with some kind of property like I can do for text box.
 
I do not think that this can be done simply. I can think of a couple of ways to do what you are asking (not real easy), but it really depends on what is the purpose. So here is some questions. Suppose you have 100 items in the list, and your window shows 10. Assume the user had items 90-100 displayed, and you could disable the scroll. Would the user then have the possibility to select items 90-100. Is the whole list disabledd. Or is this just for aesthetics. Once a value is selected you could just disable the control, and this would basically freeze the window. So this may do it.

Code:
rivate Sub Form_Current()
  List11.Enabled = True
End Sub

Private Sub List11_AfterUpdate()
  'send the focus away
  Me.txtBxA.SetFocus
  List11.Enabled = False
End Sub

If you want the possibility to select from the remaining 9 choices in the window, that would be a trickier problem. Still do not know why you want to disable the scroll, and how you want it to work.
 
I think what MajP is trying to say is that you don't need to do anything about the scroll bars of a list box using vba. They automatically do not appear if the contents all appear. If they do not appear, the scroll bars automatically show up again.

I did not see any property in the properties dialog of the list box that even allow the scroll bars to be turn on or off, so I don't think you CAN adjust them in VBA. Typically, the properties available in design view pretty much match what you can do in vba.
 
I see.
The drag and drop control I'm using on List Box is not very friendly user. When you drag and Item to a List Box below, it auto-scroll the current List Box which throws off the user. Say I have a 200 items on the List Box A, and I'm draging an Item South, it'd scroll all the way down to the bottom of List Box A.
If I can disable the scroll bar on mouse down ( which is dragging and item on list box) the user will still have his/her current selected item showing on List Box A.

I think my last resort is to make a really long List Box, and put it in Form A, then add Form A to form Form B as a subform, and turn Form B subform scroll bar on/off. Do you think the subform thing would work?
 
If you have the drag and drop thing working the way you want, could you set List Box A at the start of the-drag and-drop to contain just the top n values, where n is one less than the box can contain without scrolling?
 
OK we are finally getting somewhere. You never mentioned anything about drag and drop. I think you need to explain how you are doing the drag and drop. Show some code, the recordsource of the control. I mimicked this function, and I did not have any auto scrolling problems, but you will have to clearly define the functionality.
 
I use the "Drag-N-Dropper" control. It'd be nice if I know how to tweak their code. But I don't even know where to start. It basically work as is. Their sample list box works the same way. I guess they want you to drag and drop side way. And the auto-scolling while dragging North is meant for sorting Order of list box Items ( even though it's not enable). I can't drag and drop side way, because I have a lot of data I want to look at so the Item on the list box is very wide.
 
I am not familiar with this add-in, but sounds like the problematic functionality is a purposeful feature of their code. Do they use an Access listbox or their own ActiveX listbox? I would try their tech-support they have an email on their web page.
It also sounds like this interface may not be the best option for what you need. How about rolling your own control? If I was doing this I would possibly use two subforms modified to look and act like list boxes. SubFormA on top of SubFormB. If I double click in SubFormA the item goes to subformB and vice versa. I am not a big fan of drag and drop, and I think I could make a more intuitive interface to do this same functionality.
 
Yea, I'll give their tech-support a try. But it seems like it's hard coded. That's why I was looking for away to disable things. They use Access List box with their modules.

Drag and Drop helps the user a lot with my data. Because lots of things need to be moving around all the time. Like when the customers order is complete, someone has to check the order before dragging it onto the Old Customers table. There are about six categories that a customer can be on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top