How to fix ListBox Items?

Stellaferox

Active Member
Licensed User
Hi,

Maybe a stupid question but if I want the user NOT to be able to change the items of the listbox, just to choose them, how do I do that?
Thnx
Marc
 

RandomCoder

Well-Known Member
Licensed User
Neither the ComboBox or ListBox allow the user to directly change values.
If you did want the user to be able to enter values then you would need to provide a method such as a text box and button to trigger an event that would add the text to the list.

Regards,
RandomCoder
 

specci48

Well-Known Member
Licensed User
If you are coding something for the device you should remember that a combobox isn't editable on the device due to small differences in the .Net CF.

Or is it a desktop program...?


specci48
 

RandomCoder

Well-Known Member
Licensed User
I think that you would be better placing a label over the ComboBox that mirrors the ComboBox value.

Regards,
RandomCoder
 

Stellaferox

Active Member
Licensed User
I think I didnot express myself clear enough.

I want to:
1. let the user choose from the items in the combobox
2. NOT let him change any values in the box
3. get rid of the blue colour in the box when an item is chosen

I cannot disable the box or put a label over it because then I cannot choose an item.

marc
 

specci48

Well-Known Member
Licensed User
As far as I can see:

1. That's what a combobox is designed for... => solved
2. If you run your application on a device, the entries can NOT be edited => solved
3. The selected entry is hilited as long as the focus remains to the combobox control. My (simple) suggestion: Move the actual focus to any other control within the selction_changed event:
B4X:
Sub ComboBox1_SelectionChanged (Index, Value)
    ' any control except the combobox will do
    button1.Focus
End Sub
This works as long as the user did not "tap" the combobox without changing the actual selection. => perhaps (partly) solved


specci48
 

RandomCoder

Well-Known Member
Licensed User
I think I didnot express myself clear enough.

I want to:
1. let the user choose from the items in the combobox
2. NOT let him change any values in the box
3. get rid of the blue colour in the box when an item is chosen

I cannot disable the box or put a label over it because then I cannot choose an item.

marc
My solution is to place the label only over the part of the ComboBiox that displays the text, this still allows a user to select a value yet solves all your problems ;)

Regards,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Simple but effective ;)

Regards,
RandomCoder
 
Top