Results 1 to 7 of 7

Thread: how to make listbox or combobox control not editable at run time?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Baton Rouge, Louisiana.
    Posts
    109

    Question how to make listbox or combobox control not editable at run time?

    Hello Guys,

    What i want to do is does not allow user to edit listbox or combobox items at run time. I tried to use "LOCKED" property of listbox and combobox control But it locked entire contol. User is not able to select item from control.

    How to make control un editable? So, user can not type or delete any item from control.

    Thanks in advance.

    HDave
    ~~~......Hope never dies. one has to work for it to make it reality.......~~~

  2. #2
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    You can do this to keep it from being edited...

    VB Code:
    1. Private Sub Combo1_KeyPress(KeyAscii As Integer)
    2.     KeyAscii = 0
    3. End Sub

    The problem I'm having with that is users want to be able to hit "M" and be taken to the M's in the combo box, but using the above they can't type anything.
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  3. #3
    VB Code:
    1. Object.Enabled = False

    works with alot objects

  4. #4
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    Yes, but then the control is unuseable, I think he just wants to "disable" the ability to type in the combo box.
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  5. #5
    try a difrent type of combo box

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989
    You can just make the

    VB Code:
    1. Combo1.Style = 2 'Dropdown list, no change possible, only selection of items currently in it

    and for the listbox you can record the number of items in the list at the ponit you want it disabled, and make:

    VB Code:
    1. For I = intNoOfItems to ListBox1.ListCount - 1 Step - 1
    2.    ListBox1.RemoveItem I
    3. Next I

    This should go in an event that will trigger every time a change is made, I dont know what can be used here, maybe Validate?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Location
    Baton Rouge, Louisiana.
    Posts
    109
    Thanks demotivater.

    It worked.

    Thanks.

    HDave
    ~~~......Hope never dies. one has to work for it to make it reality.......~~~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width