Disable a listbox?

desperado

Well-known member
Joined
Oct 7, 2006
Messages
68
Programming Experience
Beginner
Hi, could somebody offer me a little help please? What I need is basically a listbox which is read only and NO item can be selected in that listbox as I have Up and Down Buttons. Some would think that the above is easy why dont I just make it read only and for the moment I have made it readonly by using the following coding:

Me.Listbox1.Enabled = False
Me.Listbox1.SelectedIndex = 0

Everything is working great apart from one problem, the text in the readonly listbox appears in gray and dull which I dont want. Is there a way making the text appear a different colour? Or even better another way around disabling selecting an item from the listbox without making it read only?

All suggestions welcome. Thanks
 
hmm.. so you want a listbox that is disabled, but it doesnt look disabled?

How much DO you want to annoy your users?

To give an analogy, there is a fire in your office. You look round and see a fire extinguisher. You pick it up, and it's about the right weight, you run to the fire and squeeze the handle, only for it to snap off revealing the object to actually be a plaster of paris theatrical imitation fire extinguisher.

How bothersome eh?!
 
but i have supplied up and down buttons with the listbox.

To give an analogy, you are placed in the same scenario as yours and when you are about to use the fire extinguisher you figure out it aint a good extinguisher but it does the job that any normal extinguisher would do by killing the fire.

How effective eh?
 
but i have supplied up and down buttons with the listbox.
So, if I want to select Item 50, i have to click a button 49 times, rather than use a scrollbar and a single click. I've uninstalled programs for more minor HCI crimes than that...

To give an analogy, you are placed in the same scenario as yours and when you are about to use the fire extinguisher you figure out it aint a good extinguisher but it does the job that any normal extinguisher would do by killing the fire.

Hangon.. I'm not the one providing a lame, crippled, counter-intuitive, non-standard fire extinguisher..

If someone from Chubb came round to my office and said "hey, this is our new fire extinguisher. You have to enter a 47 digit pin code and then wind 2 small handles continuously with both hands to get the water to flow, but dont worry, because we've made the nozzle out of stiff wire so you can set the extinguisher down, point it at the blaze then use both hands on the handles"

The guy would be out of my office for wasting my time, and I'd get on the phone to a competitor..

:)
 
It's not about winning or losing; discussion is to promote more sensible thought patterns.. Hopefully it's prompted you to think about the HCI of your interface - several times I've designed a program and it's felt ok while designing it, but after using it for 10 minutes, I've become annoyed with my own design and torn it down again..
 
Well, after this discussion with you I have got rid of the up and down buttons I just have a plain old listbox, thanks as you've given me alot of help.
 
Incidentally, I've seen similar things in, say.. Microsoft Access..

A list of fields is presented on the left (maybe "fields in the table")
Clicking > moves the selected field to the right (maybe "fields you want in the report")
Clicking >> moves all fields
Vice versa < and << move one/all back again
Double clicking an item in either list moves it to the other list

I'm thinking you could do the same thing with your listboxes, and your datatable..


If you have a datatable that has:

ListboxDisp, ItemDesc, ItemQty, RequestedQty

CLicking on items to move them would change the quantities.. Listbox1 on the left only shows items whose (ItemQty - RequestedQty) > 0 using a filter. Listbox2 on the right only shows items whose RequestedQty > 0
To "move" items between list boxes you only need alter the quantities, you dont have to actually move the items. ListboxDisp is a compound column of ItemDesc & "(" & ItemQty & ")"

I could knock up an example for you but it would be in .net 2.0 and hence not openable by you.. Maybe a 1.1 user could do a quick demo?
 
CJard that would be great if you could do that, yeh i think thats where the problems going to come from as I dont use Vb2005, but 2003. Maybe someone else could do a quick demo please. If not, then I would be happy with your version in 2005, as when I go to college they use 2005 and I could have a look at it there, but at home I use 2003 as im more familiar with this version.
 
Here's the demo. I dont normally leave an EXE in the zip but because you wont succeed in compiling the source on 1.1 (actually, you might if you manually import the relevant bits..) you might want to see how things work. You can read the code in notepad.. You will neet .NET framework 2.0 installed to run this (as with all .NET 2 apps)

Permission is given for free use in any personal or commercial pursuit provided an acknowledgement is maintained, with the restriction that this work must not be used where a test of skill directly relating to the performance of the work within an academic context (e.g. coursework, homework etc) is in place.

In summary; you can do whatever you like with it, so long as it isnt plagiarism for academia.
 

Attachments

  • TwoLists.zip
    36.2 KB · Views: 18
Back
Top