Ticket Q582123
Visible to All Users

clearing and adding a new Binding to LookUpEdit.DataBindings still shows the previous Binding

created 11 years ago

Hello,

I'm having some trouble with the DataBindings of the LookUpEdit control. I have some code that determines which set of enums should be available to choose from in a LookUpEdit based on various things. The basic approach I take is the following:

C#
if (something) { ... layoutControlItem1.Control.DataBindings.Clear(); layoutControlItem1.Control.DataBindings.Add(new Binding("EditValue", dataFeatures, "LongitudinalWeldType", true)); ... } else { ... layoutControlItem1.Control.DataBindings.Clear(); layoutControlItem1.Control.DataBindings.Add(new Binding("EditValue", dataFeatures, "LocationInWall", true)); ... }

however, even though the code flow executes correctly and the correct Binding is added to the emptied DataBindings, but the LookUpEdit control in the LayoutControlItem still shows the enum values associated with the LongitudinalWeldType enum. Is there anything else I need to do to make sure the new list of choices become available?

Comments (2)

    That was it. Thank you. I guess I don't understand the binding stuff too well. Can you briefly describe the difference between a DataSource and a DataBinding in this context?

    DevExpress Support Team 11 years ago

      Hi,
      I've moved Nikita's comment to the answer section.
      To bind the LookUpEdit's EditValue to a data source, call the LookUpEdit.DataBindings.Add method with corresponding parameters.
      To bind the LookUpEdit's drop-down list to a data source, assign this data source to the LookUpEdit.Properties.DataSource property.
      When customizing LookUpEdit, it's necessary to perform these data source bindings. It's also important to customize the LookUpEdit.Properties.ValueMember and LookUpEdit.Properties.DisplayMember properties correctly.
      Please refer to the LookUpEdit Class article for more details.

      Answers approved by DevExpress Support

      created 11 years ago (modified 11 years ago)

      [Posted by Nikita (DevExpress Support)] :
      Hello,
      The provided code is intended to bind a LookUp selected value to a datasource value. If you need to change an available set of data, it is necessary to change the LookUpEdit.Properties.DataSource property instead.
      Please let us know whether or not it meets your requirements. If you still need assistance, please send us a sample project thai illustrates your scenario. I hope to hear from you soon.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.