简体   繁体   English

在c#中的devexpress gridview中的ListBox

[英]ListBox in devexpress gridview in c#

I have a gridview as you can see here: 我有一个gridview,你可以在这里看到:

在此输入图像描述

As you can see i read the data in materialrequestcontractorId i have a listbox that this listbox reads its value from the database as you can see here: 正如你所看到我在materialrequestcontractorId读取数据我有一个列表框,这个列表框从数据库中读取它的值,你可以在这里看到:

List<MaterialRequestContractor> lstMRC = _materialRequestContractorRepository.Get().ToList();
            foreach (MaterialRequestContractor VARIABLE in lstMRC)
            {
                LstMaterialRequestContractorId.Items.Add(VARIABLE.Id);
            }

But the problem is i need to show my user the name of my MaterialRequestContractor not its id ,the id should be the value of my name and be saved in database .but in devexpress i can't assign this value and text to list box? 但问题是我需要向我的用户显示我的MaterialRequestContractor的名称而不是它的id ,id应该是我的名字的值并保存在数据库中。但在devexpress中我不能将此值和文本分配给列表框?

I have a record in my MaterialRequestContractor database with id=1

DevExpress provides several lookup editors for WinForms (LookUpEdit, GridLookUpEdit, SearchLookUpEdit) which support such scenario out-of-the-box. DevExpress为WinForms(LookUpEdit,GridLookUpEdit,SearchLookUpEdit)提供了几个查找编辑器,它们支持这种开箱即用的场景。 The idea is that LookUp editor has its own data source. 想法是LookUp编辑器有自己的数据源。 When it is shown in the grid, it finds a value with from the grid cell in its data source (the key column determined by the LookUpEdit.Properties.ValueMember property) and shows the value from a field that selected as DisplayMember. 当它显示在网格中时,它会从其数据源中的网格单元格(由LookUpEdit.Properties.ValueMember属性确定的键列)中找到一个值,并显示选择为DisplayMember的字段中的值。 So if you put a table that has MaterialRequestContractor and MaterialRequestContractorId fields, and properly select DisplayMember and ValueMember, the DevExpress grid should work just like you described. 因此,如果您放置一个包含MaterialRequestContractor和MaterialRequestContractorId字段的表,并正确选择DisplayMember和ValueMember,DevExpress网格应该像您描述的那样工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM