Ticket T299653
Visible to All Users

LookUpEdit doesn't synchronized with CurrencyManager

created 9 years ago (modified 9 years ago)

[DevExpress Support Team: CLONED FROM A2275: ComboBox - Implement lookup feature with data binding]
I tested further. No, this horrible DEFECT (BUG) is still not fixed. You people say that it is "designed behavior", but you know that a bindable control should move the position of the BindingSource. Period, end of story. We all know it and you all know it, so stop being FEMS and own up to it. Most of all, fix this STUPIDITY. You people charge money for this?
In addition, your so-called "workaround" above, in VB.NET, suffers from two problems:

  1. It doesn't work.
  2. It's very poorly written. Take some classes! You don't even have a handler, for God's sake. Geez…
    If the user selects the record at index 0 the binding manager isn't going to change position (from zero). Therefore, the BindingSource.CurrentChanged event won't fire. The need to work around your crap 'workaround' is utterly disappointing. How much money do you people spend to release broken controls? How embarassing…
       Private Sub SearchEmployeeGridLookUpEdit_EditValueChanged(sender As Object, e As System.EventArgs) Handles SearchEmployeeGridLookUpEdit.EditValueChanged
           Dim editor = DirectCast(sender, GridLookUpEdit)
           If Not IsNothing(editor.Properties.DataSource) Then
               Dim manager = Me.BindingContext(editor.Properties.DataSource)
               Dim index = editor.Properties.GetIndexByKeyValue(editor.EditValue)
               If index = 0 Then
                   manager.Position = 1
               End If
               manager.Position = editor.Properties.View.GetDataSourceRowIndex(index)
           End If
       End Sub

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hello,
I regret to hear that you are faced with the difficulties using our controls. Indeed, we do not support the synchronization of a selected item with the Currency Manager.
Our LookUp editors are intended to show data from a related table and can be used in in-place mode (for instance, inside the grid). That is why their behavior is different than the default .NET ComboBox.
However, there is an easy-to-use workaround that makes our LookUp editors behave like the default .NET ComboBox. You can handle only the EditValueChanged event as it is demonstrated in the ComboBox - Implement lookup feature with data binding ticket. Or, you can implement such a functionality at the descendant level by overriding the OnEditValueChanged method, as described in the LookUpEdit doesn't update the CurrencyManager.Position property ticket.
It is not fully clear why this workaround does not work in your case. I have tested Nikita's project and it works correctly on my side. I also don't see a possible cause of the issue in the provided code snippet.
I have attached a VB sample and a video that illustrates how this project behaves on my side. As you can see, bindings work properly in this case.
If it is not suitable in your scenario, please describe it in greater detail so that we can suggest the best approach.
We will also consider improving the mechanism of interaction of our controls with the Currency Manager. Currently, however, I cannot provide any ETA for this task.
I am looking forward to your response.

    Comments (2)

      The provided code snippet is my fix to your non-working so-called "workaround"!
      Comment my lines:
                If index = 0 Then
                     manager.Position = 1
                 End If
      …run the thing and select the first item on the list. The BindingSource.CurrentChanged event doesn't fire, because its position is already 0 (zero) - yet the control says "[EditValue is null]", for some reason I've yet to determine.
      A real ComboBox doesn't have this mysterious "[EditValue is null]" string in it - it displays the DisplayMember from the data source. Why yours has this crazy text in it, I don't know - but it has been assigned a data source with valid values. It should show the DisplayMember value at position 0 (zero). And when the data source is initially assigned, BindingSource.CurrentChanged should fire at least once.
      If you're going to support databinding then support all of it, or don't even bother. I'm forced to use your junk controls on this project and I find the most common ones are broken.
      For example, I bound a TextEdit (didn't you mean to name this thing TextBox?) to a BindingSource whose data source is a business object and fired up the form. The BindingSource is not yet bound - this is accomplished later by making a selection in a "ComboBox" - your "LookUpEdit" - if I give the aforementioned "TextEdit" focus and tab to another control, a red error indicator appears next to the control which says, "Index -1 does not have a value."
      This happens to every control type I've put on the form with the exception of a couple of LookUpEdits. Why those 2 or 3 LookUpEdits do NOT display the error indicator I do not know. They're no different from the ones which do display it.
      I am under the impression that the "Index -1 does not have a value." issue was recently introduced as a "breaking change".  No doubt you'll tell me it's a "feature".

      DevExpress Support Team 9 years ago

        Hello,
        As I said in my previous answer, LookUpEdit doesn't synchronize it's edit value with the BindingManagerBase. LookUp editors are not a direct analog of the default WinForms component. They are intended to show data by a foreign key. So in most cases, it doesn't need Currency Manager synchronization. Moreover, this editor can be used in in-place mode and in this case, there is no simple way to work Currency Manager.

        LookUp editors display "[EditValue is null]" if they cannot find a row that contains the LookUp's EditValue in the column selected in the ValueMember Property. The provided information is insufficient to determine why data is not shown in the LookUp in your case. It seems that you have some specifics that are not mentioned in your description.
        I have attached a project that illustrates how the LookUp behaves in a common case. Since the problem seems to be caused by some specifics of your databinding scenario, we need full information about the scenario. Please modify the attached project to illustrate the issue and I and my colleagues will do our best to find an appropriate solution.

        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.