Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi,
                                        Can you please advise how I can use the lookup edit in an XtraGrid row column. Iwould like to be able to do the following:
                                    1. When selecting the lookup edit in a row in the grid it shows a list of items from another table in my database.
                                    2. When the required item is selected in the lookup edit it then takes some of the column values from the source and adds them to columns in the current row.

                                    Is there any examples of how to do this??

                                    Regards..
                                    Peter

                                0

                                Hi Peter,

                                Thanks for your question. All that you need is to assign following properties:

                                RepositoryItemLookUpEdit.DataSource property to an appropriate data source.
                                RepositoryItemLookUpEdit.DataMember property to the string matching the name of the column from which to load display values.
                                RepositoryItemLookUpEdit.ValueMember property to the string matching the name of the column from which to load real editor values.

                                Then, add this RepositoryItemLookUpEdit to the GridControl.RepositoryItems collection, and assign it to the ColumnEdit property of an appropriate GridColumn.

                                Thanks,
                                Uriah.

                                0

                                Uriah,
                                   Thanks for the reply, by following the links you provided in your reply this only allows the assigning of a value for a single column that the Lookup Edit control resides in. I need to be able to select the value from the Lookup edit in column 1(where the Lookup edit resides) and once selected I need it to populate the remaining cells in the selected(current) row with the values from the selected row in the Lookup Edit control in column 1.

                                Hope this explains it better.

                                Regards..
                                Peter

                                0

                                Uriah,
                                    Also I just noticed that the Lookup Edit doesn't show the existing column data when not in edit view or when it is in edit view. I followed all the instructions.

                                Regard..
                                Peter.

                                0

                                Hi Peter,

                                I've created a small sample project illustrating how your task can be accomplished.
                                Please review it, and let me know whether it helps you.

                                Thanks
                                Dimitros

                                dxSample.zip
                                0

                                Dimitros,
                                      Thanks for the reply, unfortunately your solution is unworkable because the Lookup source has 19 Columns (I have only defined 4 columns to show in the lookup) and the destination grid only requires 4 of the columns returned from the Lookup plus there is a 5th column which I need to set a calculated value so when I try to implement your example it errors:

                                 "Input array is longer than the number of columns in this table"

                                Is there anyway to manually add the items required from the source array??

                                Regards..
                                Peter

                                0

                                Hi Peter,

                                My project just illustrates the main idea how your task can be accomplished. However, you need to override the CopyValues method according to your application's logic manually.

                                Though, your question is not directly related to our products, I will provide you with some general advice, which I hope will be of help to you.

                                You can access row values using the following code:

                                	
                                [C#]
                                row[<FieldName>] = <value>

                                The DataRow class is a standard class. So, to get more information about it, please refer to MSDN documentation.

                                Thanks
                                Dimitros

                                0

                                Dimitros,
                                            Thank you for your response, I am still working on getting the add part to work (I have encountered other issues which I need to resolve first).

                                I have attached a sample project that displays one of the issues that I have had right from the beginning and that is once the lookup editor is placed into the column I no longer see the value, the column is blank.

                                Can you please advise on this particular issue.

                                Thanks
                                Peter

                                DXLookup.rar
                                0

                                Hi,
                                   Have got it sorted using the following code:

                                	
                                [C#]
                                private void repositoryItemLookUpEdit1_EditValueChanged(object sender, EventArgs e) { LookUpEdit edit = sender as LookUpEdit; DataRow sourceDataRow = (edit.Properties.GetDataSourceRowByKeyValue(edit.EditValue) as DataRowView).Row; DataRow targetDataRow = gridView1.GetDataRow(gridView1.FocusedRowHandle); CopyValues(sourceDataRow, targetDataRow); } public void CopyValues(DataRow sourceDataRow, DataRow targetDataRow) { if (sourceDataRow == null || targetDataRow == null) return; targetDataRow["Inv_Number"] = txtInv.Text.Trim(); targetDataRow["Customer_Code"] = txtCust.Text.Trim(); targetDataRow["Date"] = DateTime.Today; targetDataRow["GST_Inc"] = txtGSTInc.Text.Trim(); targetDataRow["GST%"] = txtGst.Text.Trim(); targetDataRow["Part_Code"] = sourceDataRow["Code"]; targetDataRow["Part_Description"] = sourceDataRow["Description"]; targetDataRow["Part_Cost"] = sourceDataRow["Sell_Inc_GST"]; targetDataRow["Qty"] = 1; //targetDataRow.EndEdit(); }

                                Regards..
                                Peter

                                0

                                Hi,
                                  Added code here it didn't seem to show when I posted but was in my email advsing I had updated the post??

                                        private void repositoryItemLookUpEdit1_EditValueChanged(object sender, EventArgs e)
                                        {
                                            LookUpEdit edit = sender as LookUpEdit;
                                            DataRow sourceDataRow = (edit.Properties.GetDataSourceRowByKeyValue(edit.EditValue) as DataRowView).Row;
                                            DataRow targetDataRow = gridView1.GetDataRow(gridView1.FocusedRowHandle);
                                            CopyValues(sourceDataRow, targetDataRow);
                                        }

                                        public void CopyValues(DataRow sourceDataRow, DataRow targetDataRow)
                                        {
                                            if (sourceDataRow == null || targetDataRow == null)
                                                return;
                                            targetDataRow["Inv_Number"] = txtInv.Text.Trim();
                                            targetDataRow["Customer_Code"] = txtCust.Text.Trim();
                                            targetDataRow["Date"] = DateTime.Today;
                                            targetDataRow["GST_Inc"] = txtGSTInc.Text.Trim();
                                            targetDataRow["GST%"] = txtGst.Text.Trim();
                                            targetDataRow["Part_Code"] = sourceDataRow["Code"];
                                            targetDataRow["Part_Description"] = sourceDataRow["Description"];
                                            targetDataRow["Part_Cost"] = sourceDataRow["Sell_Inc_GST"];
                                            targetDataRow["Qty"] = 1;
                                            //targetDataRow.EndEdit();
                                        }

                                Regards
                                Peter

                                0

                                Hi Peter,

                                I am glad to hear that you have found a solution. Thank you for letting us know of your progress.

                                Your code is not visible because the "<*code></code>" block is not recognized. Please use the following tags instead (without "*"):
                                <*code lang="cs">
                                 
                                </code>

                                Thanks
                                Dimitros

                                0

                                Thanks for the information.

                                Regards..
                                Peter

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners