Hello to all.
i have a problem with LookupEdit control.
i use this code
lkedtAddressB.DataBindings.Add("EditValue", DtAddressB, "CustomerAddressID");
lkedtAddressB.Properties.DataSource = DtAddressB;
lkedtAddressB.Properties.DisplayMember = "Descr";
lkedtAddressB.Properties.ValueMember = "CustomerAddressID";
lkedtAddressB.Properties.NullText = "----- Empty Address -----";
LookUpColumnInfoCollection col1 = lkedtAddressB.Properties.Columns;
col1.Add(new LookUpColumnInfo("Descr", 0));
lkedtAddressB.Properties.BestFit();
lkedtAddressB.Properties.SearchMode = SearchMode.AutoComplete;
lkedtAddressB.Properties.AutoSearchColumnIndex = 1;
lkedtAddressB.EditValue = CustomerAddressDeliveryID; //here is the problem
the problem is that i want to change the EditValue by hand and when i give the CustomerAddressDeliveryID value doesnt change the current value of LookupEdit.
The same issue when i try to give the value by hand (lkedtAddressB.EditValue = 100)
why this isnt working?
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.
Hi Peter,
Thank you for your code snippet.
A possible cause of the problem is that you bind your LookUpEdit to the same datasource that is displayed in the dropdown window. This means that each time you are changing the editor's EditValue, the focused record's value in the DtAddressB table is changed. As a result, two rows in the DtAddressB table have the same value in the "CustomerAddressID" column which is not correct. The LookUpEdit uses key values to identify rows. So, in your scenario the LookUpEdit can behave incorrectly. It's not quite clear for which purpose you've added the following line:
lkedtAddressB.DataBindings.Add("EditValue", DtAddressB, "CustomerAddressID");
Please try to comment it and check that you are setting the editor's EditValue to a unique value that presents in the DtAddressB table.
Thanks
Dimitros
if i comment this line i know is working but i dont understand clearly why doesnt work.
I tried to use it this way because i have already a default Value for CustomerAddressID and when i reach this part of code in LookupEdit i want to have access in all CustomerAddresses but to show what is the selected value from default Parameters.
So if you continue to save your work you have already a default value but if you change the value from the lookupedit then the EditValue will be affected from DataBinding.
The CustomerAddressID is unique.
but if i comment the line yes it works.
Hi Peter,
The cause of the problem is that the same data source (DtAddressB) in your code is used both to fill the drop down list and as a data source to which the LookUpEdit is bound. With this adjustment, according to the .NEt Framework data-biding mechanism, the editor's value should be always synchronized with the current row's CustomerAddressID field. So when you are selecting a customer address entry from the drop-down window, the lookup gives its ValueMember's value (actually the selected row's CutomerAddressID) and passes it to another customer address' CustomerAddressID field that is currently focused within the data source. This change cannot be performed, because this will cause a data inconsistency and duplicate unique keys. I think that your approach is incorrect, which causes unpredictable behavior. However, if you describe your requirements in greater detail, I'll do my best to give you a prompt solution. Please explain why you need to use the same data source both for the data-binding and to show the items list? For what purpose are you binding the editors to this data source?
I'm looking forward to hearing from you.
Thanks,
Stan.