Devexpress lookup edit select 一项填写rest lookups

Devexpress lookup edit select one fill in rest lookups

我正在开发使用 xpo 集合从数据库获取和更新数据的程序。我设置了 lookupedit 以从另一个数据库(国家名称)获取数据我希望在选择国家名称后自动填写另一个 lookupedit(国家代码)。

这是 XPO 合集:

Private Countries As New XPCollection(Of clCountry)(UOW)

这是查找代码:

CountriesLookupRepo.DataSourceConnect("Name", "Name", Countries)
CountryCodeLookUp.DataSourceConnect("ISO2", "ISO2", Countries)

如何link 设置它们以便在选择名称后自动填充 ISO2?

谢谢

我建议您通过这个 DevExpress 线程,它描述了实现此功能的大多数情况。

How to filter a second LookUp column based on a first LookUp column's value

GridControl, TreeList, and VGridControl provide a special event that is raised when a cell editor is activated: ShownEditor. This is the best moment to replace the LookUp editor's data source with the collection filtered by an appropriate criterion.

示例:

Private Sub gridView1_ShownEditor(ByVal sender As Object, ByVal e As EventArgs)
    Dim view As ColumnView = DirectCast(sender, ColumnView)
    If view.FocusedColumn.FieldName = "CityCode" AndAlso TypeOf view.ActiveEditor Is LookUpEdit Then
        Dim edit As LookUpEdit = CType(view.ActiveEditor, LookUpEdit)
        Dim countryCode As String = CStr(view.GetFocusedRowCellValue("CountryCode"))
        edit.Properties.DataSource = GetFilteredCities(countryCode)
    End If
End Sub

有关使用 LookupEdit 绑定 XPO 对象的更多信息,请查看此知识库示例:

How to: Bind an XPCollection to a LookUp

示例:

XPCollection xpCollectionPerson = new XPCollection(typeof(Person));         
xpCollectionPerson.DisplayableProperties = "Name;Group!Key";
gridControl1.DataSource = xpCollectionPerson;

XPCollection xpCollectionGroup = new XPCollection(typeof(PersonGroup));
RepositoryItemLookUpEdit lookUpRI = new RepositoryItemLookUpEdit();
lookUpRI.DataSource = xpCollectionGroup;
lookUpRI.DisplayMember = "GroupName";
lookUpRI.ValueMember = "Oid";
gridControl1.RepositoryItems.Add(lookUpRI);
// Associate the LookUpEdit editor with the "Group!Key" column. 
(gridControl1.MainView as ColumnView).Columns["Group!Key"].ColumnEdit = lookUpRI;

希望对您有所帮助。

想出了怎么做。

如果有人想知道,我就是这样做的:

Dim Country As clCountry = CountriesLookupRepo.GetDataSourceRowByKeyValue(e.Value)
                Apt.CountryCode = Country.ISO2
                Apt.RegionName = Country.Region