我在UltraGrid中设置了一个UltraCombo,AutoComplete设置为“建议”。UltraCombo具有“Name”的DisplayMember和“ID”的ValueMember。我发现,当我将DataFilter附加到UltraCombo时(我想在值为零时使其显示为空),如果他们键入的数字恰好与ID匹配,并且还以Name开头,它将自动完成,但底层值从未更改。因此,不会触发AfterUpdate或CellChange,当您离开单元格时,它将变为空白。如何让“自动完成”工作,但仍将零值显示为空白?以下是我的代码(注意,如果您注释掉设置UltraCombo1.DataFilter的行,更新可以正常工作,但您会丢失DataFiltering):
Imports Infragistics.Win.UltraWinGrid
Imports Infragistics.Win
Public Class Form1
Public Sub New()
InitializeComponent()
Dim datatableCombo = New DataTable
datatableCombo.Columns.Add("ID", GetType(Integer))
datatableCombo.Columns.Add("Name", GetType(String))
datatableCombo.Rows.Add({1, "123"})
datatableCombo.Rows.Add({2, "234"})
datatableCombo.Rows.Add({3, "456"})
UltraCombo1.DataFilter = New MyDataFilter()
UltraCombo1.DataSource = datatableCombo
UltraCombo1.ValueMember = "ID"
UltraCombo1.DisplayMember = "Name"
Dim position As Integer = 0
UltraCombo1.DisplayLayout.Bands(0).Columns("ID").Hidden = False
UltraCombo1.DisplayLayout.Bands(0).Columns("ID").Header.VisiblePosition = position
position += 1
UltraCombo1.DisplayLayout.Bands(0).Columns("Name").Hidden = False
UltraCombo1.DisplayLayout.Bands(0).Columns("Name").Header.VisiblePosition = position
position += 1
Dim datatableGrid = New DataTable
datatableGrid.Columns.Add("ID", GetType(Integer))
datatableGrid.Columns.Add("Name", GetType(String))
UltraGrid1.DataSource = datatableGrid
UltraGrid1.DisplayLayout.GroupByBox.Hidden = True
UltraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True
UltraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom
UltraGrid1.DisplayLayout.Bands(0).Columns("ID").EditorComponent = UltraCombo1
UltraGrid1.DisplayLayout.Bands(0).Columns("ID").CellClickAction = CellClickAction.EditAndSelectText
UltraGrid1.DisplayLayout.Bands(0).Columns("ID").Style = ColumnStyle.DropDownValidate
End Sub
Public Class MyDataFilter
Implements Infragistics.Win.IEditorDataFilter
Public Function Convert(ByVal convertArgs As Infragistics.Win.EditorDataFilterConvertArgs) As Object Implements Infragistics.Win.IEditorDataFilter.Convert
' Shouldn't affect anything?
convertArgs.Handled = False
Return Nothing
End Function
End Class
End Class