ComboBox.edit.false ??? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

ComboBox.edit.false ???

eaglemaneagleman Posts: 28Member
Hi

This should be easy. I have a combobox with a few entrances to choose from. Is there a property that makes it impossible to edit in the combobox or another way to make this possible when the program is running? I cant find a usable property for this.

Thanks for any guidance
Ealeman

Comments

  • kainsworthkainsworth Posts: 200Member
    Hi

    "This should be easy" - Always makes me chuckle, that! It's usually the opposite, but in this case it's not so hard.

    In the keyPress event of your combobox, put this line:
    [code]
    e.Handled = True
    [/code]




    : Hi
    :
    : This should be easy. I have a combobox with a few entrances to choose from. Is there a property that makes it impossible to edit in the combobox or another way to make this possible when the program is running? I cant find a usable property for this.
    :
    : Thanks for any guidance
    : Ealeman
    :
    :

  • kainsworthkainsworth Posts: 200Member
    I'm not entirely sure from the wording of your question whether you want the ability to turn the editing on and off during runtime. (The example I gave won't allow editing at all, but the user can still make choices from the combo's list).
    If you want to give the user choice at run time, one way is to create a boolean variable and use this as the switch to allow or not allow text editing.
    Here's some sample code:
    [code]
    ' At the top of your form:
    Dim blnEditAllowed As Boolean = False

    ' then in the form's code at some trigger point decided by you:
    blnEditAllowed = True

    ' Change the KeyPress event, like so:
    Private Sub ComboBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox2.KeyPress
    If Not blnEditAllowed Then e.Handled = True
    End Sub
    ' (That code is a bit back-to-front - it can be turned round to avoid using the negative, but you can tweak the code that way if you use it)
    [/code]
    Now user can or cannot edit depending on which valeu you have assigned to the boolean.

    =========================================================

    : Hi
    :
    : "This should be easy" - Always makes me chuckle, that! It's usually the opposite, but in this case it's not so hard.
    :
    : In the keyPress event of your combobox, put this line:
    : [code]
    : e.Handled = True
    : [/code]
    :
    :
    :
    :
    : : Hi
    : :
    : : This should be easy. I have a combobox with a few entrances to choose from. Is there a property that makes it impossible to edit in the combobox or another way to make this possible when the program is running? I cant find a usable property for this.
    : :
    : : Thanks for any guidance
    : : Ealeman
    : :
    : :
    :
    :

  • eaglemaneagleman Posts: 28Member
    Hi kainsworth

    I just wanted to turn of the editing ability
    I will try your solution. Thanks for your answer and time.

    //Eagleman


    : I'm not entirely sure from the wording of your question whether you want the ability to turn the editing on and off during runtime. (The example I gave won't allow editing at all, but the user can still make choices from the combo's list).
    : If you want to give the user choice at run time, one way is to create a boolean variable and use this as the switch to allow or not allow text editing.
    : Here's some sample code:
    : [code]
    : ' At the top of your form:
    : Dim blnEditAllowed As Boolean = False
    :
    : ' then in the form's code at some trigger point decided by you:
    : blnEditAllowed = True
    :
    : ' Change the KeyPress event, like so:
    : Private Sub ComboBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox2.KeyPress
    : If Not blnEditAllowed Then e.Handled = True
    : End Sub
    : ' (That code is a bit back-to-front - it can be turned round to avoid using the negative, but you can tweak the code that way if you use it)
    : [/code]
    : Now user can or cannot edit depending on which valeu you have assigned to the boolean.
    :
    : =========================================================
    :
    : : Hi
    : :
    : : "This should be easy" - Always makes me chuckle, that! It's usually the opposite, but in this case it's not so hard.
    : :
    : : In the keyPress event of your combobox, put this line:
    : : [code]
    : : e.Handled = True
    : : [/code]
    : :
    : :
    : :
    : :
    : : : Hi
    : : :
    : : : This should be easy. I have a combobox with a few entrances to choose from. Is there a property that makes it impossible to edit in the combobox or another way to make this possible when the program is running? I cant find a usable property for this.
    : : :
    : : : Thanks for any guidance
    : : : Ealeman
    : : :
    : : :
    : :
    : :
    :
    :

Sign In or Register to comment.