How to fix ListBox Items?

Discussion in 'Questions (Windows Mobile)' started by Stellaferox, Feb 19, 2008.

  1. Stellaferox

    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
     
  2. specci48

    specci48 Well-Known Member Licensed User

    Do you really think of a listbox or of a combobox?
     
  3. Stellaferox

    Stellaferox Active Member Licensed User

    I am sorry, of course I mean a combobox....:sign0013:
     
  4. RandomCoder

    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
     
  5. specci48

    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
     
  6. Stellaferox

    Stellaferox Active Member Licensed User

    It is essentially a PPC program. I want to get rid of the blue background of the item as well.
     
  7. RandomCoder

    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
     
  8. Stellaferox

    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
     
  9. specci48

    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:
    Code:
    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
     
  10. Stellaferox

    Stellaferox Active Member Licensed User

    Yes, I think you are right. I will use that solution. Thank as always for your help!
    Marc
     
  11. RandomCoder

    RandomCoder Well-Known Member Licensed User

    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
     
  12. Stellaferox

    Stellaferox Active Member Licensed User

    It works!
    thnx RC.
    Marc
     
  13. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Simple but effective ;)

    Regards,
    RandomCoder
     
Loading...