Results 1 to 8 of 8

Thread: [RESOLVED] Combobox binding problem

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    528

    Resolved [RESOLVED] Combobox binding problem

    I have a form with a bindingsource (bsMain) and a combobox (cboLinkID).

    The bsMain properties are as follows.

    Code:
    With bsMain
        .DataMember = "Accounts"   '...this is the Accounts table in the dsMain dataset
        .DataSource = dsMain
    End With
    cboLinkID.DataBindings.Add(b)
    The cboLinkID is bound as follows.

    Code:
    With cboLinkID
        .ValueMember = "RecID"  '...this is the primary key field of the Accounts table
        .DisplayMember = "Account"   '...this is the Account field of the Accounts table (i.e., account names) 
        .DataSource = dsMain.Tables("Accounts")
    End With
    
    b = New Binding("SelectedValue", bsMain, "LinkID") 
    With b
        .DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged
    End With
    cboLinkID.DataBindings.Add(b)
    The above code is executed with the form's Load method.

    When the form opens, the selected item's cboLinkID drop-down list shows all the account names in the Accounts table. The cboLinkID.SelectedValue shows the name of the linked account. This is the expected behavior.

    But when I navigate to another record, then the cboLinkID drop-down list now has no items and the cboLinkID.SelectedValue is blank.

    Closing/reopening the form repeats the above behavior.

    What am I doing wrong?
    Last edited by Mark@SF; Mar 2nd, 2025 at 05:29 PM.

Tags for this Thread

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