【发布时间】:2015-07-29 09:03:05
【问题描述】:
在我的应用程序中,我有一些代码可以在几个表单中获取,我想知道是否有人可以就如何实现这一点提供一些建议。 我有 2 个应用程序可以使用的联系人列表(接口),并根据设置确定使用内部或外部联系人列表。我正在使用 devexpress 查找编辑器,但组合框的概念应该是相似的。
我正在做的是:
Dim dt As DataTable = classContactsFunctions.GetContactList()
If dt.Rows.Count > 0 Then
With cbSupervisorID
.Properties.DataSource = dt ' Specify the data source to display in the dropdown.
.Properties.DisplayMember = "FullName" ' The field providing the editor's display text.
.Properties.ValueMember = "InterfaceCode" ' The field matching the edit value.
End With
' Add two columns to the dropdown.
Dim coll As DevExpress.XtraEditors.Controls.LookUpColumnInfoCollection = cbSupervisorID.Properties.Columns
coll.Add(New DevExpress.XtraEditors.Controls.LookUpColumnInfo("InterfaceCode", 0))
coll.Add(New DevExpress.XtraEditors.Controls.LookUpColumnInfo("Surname", 0))
coll.Add(New DevExpress.XtraEditors.Controls.LookUpColumnInfo("FirstName", 0))
cbSupervisorID.Properties.Columns("InterfaceCode").Visible = False
With cbSupervisorID
.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup ' Set column widths according to their contents and resize the popup, if required
.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoComplete ' Enable auto completion search mode.
.Properties.AutoSearchColumnIndex = 1 ' Specify the column against which to perform the search.
End With
End If
我想尝试实现的是创建一个自定义类/项目,我可以将其拖到我的表单上,并根据我的喜好重复使用它,而无需重新执行所有这些代码。希望我可以将一个查找编辑器拖到我的表单上,它会始终按照代码填充。
任何建议或方向都会很棒
【问题讨论】:
标签: vb.net devexpress