【问题标题】:Devexpress lookup edit select one fill in rest lookupsDevexpress 查找编辑选择一项填写其余查找
【发布时间】:2016-02-04 10:54:22
【问题描述】:

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

这里是 XPO 合集:

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

这里是查找代码:

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

如何将它们链接起来,以便在选择名称后自动填充 ISO2?

谢谢

【问题讨论】:

    标签: vb.net autocomplete devexpress xpo gridlookupedit


    【解决方案1】:

    想出了怎么做。

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

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

    【讨论】:

      【解决方案2】:

      我建议您阅读这个 DevExpress 线程,该线程描述了大多数情况以实现此功能。

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

      GridControl、TreeList 和 VGridControl 提供了一个特殊事件 激活单元格编辑器时引发:ShownEditor。这是 将 LookUp 编辑器的数据源替换为 按适当标准过滤的集合。

      示例:

      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 对象的更多信息,请查看以下 KB 示例:

      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;
      

      希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-09
        • 1970-01-01
        相关资源
        最近更新 更多