Results 1 to 3 of 3

Thread: [RESOLVED] Combobox not showing databound collection

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Resolved [RESOLVED] Combobox not showing databound collection

    I am using the following code for displaying table data in controls on a form:

    Code:
                txtOwner.DataBindings.Add(New Binding("Text", _MasterBase5_0DataSet, "tblValMaster.strOwner"))
    I do not fully understand the workings of this, so when the control is a combobox and it doesn't work correctly I am pretty much unable to explain why.

    Code:
            With cmbType
                .DataBindings.Add(New Binding("ValueMember", _MasterBase5_0DataSet, "lkpValType.strValType"))
                .DataBindings.Add(New Binding("DisplayMember", _MasterBase5_0DataSet, "lkpValType.strValType"))
                .DataBindings.Add(New Binding("Text", _MasterBase5_0DataSet, "tblValMaster.strValType"))
            End With
    The "Text" part of the above code behaves as expected. However, the "ValueMember" and "Display" member do not. Nothing shows from either of them. I suspect that it has something to do with the fact that it is the, "Binding" that causes the behavior.

    lkpValType is a lookup table that serves in the place of a collection that might be found in a combobox. So what should be showing is the list from table lkpValType.

    Can anyone explain to me what I am doing wrong here?

  2. #2
    Fanatic Member kpmc's Avatar
    Join Date
    Sep 2017
    Posts
    1,012

    Re: Combobox not showing databound collection

    Dont add databinding, instead add datasrouce
    IE
    Code:
            With ComboBox1
                .DataSource = CatagoryDV
                .DisplayMember = "Col1"
                .ValueMember = "Col1"
            End With

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    703

    Re: Combobox not showing databound collection

    Thanks KP, that works perfectly. Using form controls for different binding sources at different times is a new thing for me and I still do not understand all of the ways and means of doing so.

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