Combobox text not in list strange behaviour

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: clorentson (clorentson_at_discussions.microsoft.com)
Date: 03/23/05


Date: Wed, 23 Mar 2005 11:57:01 -0800

Here is a weird one. I have a combobox that accepts and displays values that
are not in the list. However if I do a droppedDown = true in the onEnter
event handler and then tab to another combobox, the text value is reset to
null/empty string. My solution at this point is to separate the two
comboboxes with a textbox so that doesn't happen. (Note that it also resets
to null if i step through through the droppeddown = true statement.)

If anyone has seen this or heard of fix for it, please let me know.

Thanks,
Carl

Here are code snippets pertainent to this:

        '
        'cboPaymentType
        '
        Me.cboPaymentType.Enabled = False
        Me.cboPaymentType.Location = New System.Drawing.Point(152, 160)
        Me.cboPaymentType.Name = "cboPaymentType"
        Me.cboPaymentType.Size = New System.Drawing.Size(104, 21)
        Me.cboPaymentType.TabIndex = 2
        '
        'cboPaymentMethod
        '
        Me.cboPaymentMethod.Enabled = False
        Me.cboPaymentMethod.Location = New System.Drawing.Point(320, 160)
        Me.cboPaymentMethod.Name = "cboPaymentMethod"
        Me.cboPaymentMethod.Size = New System.Drawing.Size(104, 21)
        Me.cboPaymentMethod.TabIndex = 4

        'payment type
        Me.cboPaymentType.DataBindings.Add("SelectedValue", Me.OrderDS,
"Orders.OrdersOrderPayments.PaymentTypeFK")
        ' binding to the Text property appears to allow a value not in the
list to be entered, saved, and displayed.
        Me.cboPaymentType.DataBindings.Add("Text", Me.OrderDS,
"Orders.OrdersOrderPayments.PaymentTypeFK")
        Me.cboPaymentType.DataSource = Me.PaymentTypeDS
        Me.cboPaymentType.DisplayMember = "PaymentType.PaymentTypeName"
        Me.cboPaymentType.ValueMember = "PaymentType.PaymentTypeName"
        ' do it twice to get around bug
        Me.cboPaymentType.SelectedIndex = -1
        Me.cboPaymentType.SelectedIndex = -1
        'payment method
        Me.cboPaymentMethod.DataBindings.Add("SelectedValue", Me.OrderDS,
"Orders.OrdersOrderPayments.PaymentMethodFK")
        ' binding to the Text property appears to allow a value not in the
list to be entered, saved, and displayed.
        Me.cboPaymentMethod.DataBindings.Add("Text", Me.OrderDS,
"Orders.OrdersOrderPayments.PaymentMethodFK")
        Me.cboPaymentMethod.DataSource = Me.PaymentMethodDS
        Me.cboPaymentMethod.DisplayMember = "PaymentMethod.PaymentMethodName"
        Me.cboPaymentMethod.ValueMember = "PaymentMethod.PaymentMethodName"
        ' do it twice to get around bug
        Me.cboPaymentMethod.SelectedIndex = -1
        Me.cboPaymentMethod.SelectedIndex = -1

    Private Sub cboPaymentMethod_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboPaymentMethod.Enter
        CType(sender, ComboBox).DroppedDown = True
    End Sub

    Private Sub cboPaymentType_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboPaymentType.Enter
        CType(sender, ComboBox).DroppedDown = True
    End Sub



Relevant Pages

  • Re: Keeping Variables Alive
    ... I declared the public collection in a standard module without the New word ... The collection still reset to nothing when I added the second combobox. ... Private Sub CommandButton1_Click ...
    (microsoft.public.excel.programming)
  • Re: Can I implement an autofill feature with a textbox?
    ... As it turns out Greg Dunn's example using a combobox does NOT require you to ... set the DroppedDown on entry and it DOES work with a Simple style combo. ... > text as it is typed in or even when the cbo loses focus. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: DroppedDown
    ... I want to drop down a combobox when the mouse enters and collapse it ... in the droppeddown portion of the combobox droppeddown is closing. ... Plz Help me to solve this problem sir as it is really really high priority. ... It will not release capture until the window is ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Open a combobox
    ... 'DroppedDown' /is/ a member of the Windows Forms combobox control! ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ComboBox and automatic dropDown
    ... > if the user tabs to the comboBox ??? ... Add a handler to the control's 'Enter' event and set its 'DroppedDown' ...
    (microsoft.public.dotnet.languages.vb)