DataFilter在UltraGebo UltraGrid内部干扰AutoComplete

时间:2016-03-03 20:27:58

标签: vb.net infragistics

我在UltraGrid中设置了UltraCombo,AutoComplete设置为"建议"。 UltraCombo的DisplayMember为" Name"和#34; ID"的ValueMember。我发现当我将一个DataFilter附加到UltraCombo时(我想在值为零时使其显示为空白),如果他们输入的数字恰好与ID匹配并且也开始一个名称,它将执行自动完成,但基础值永远不会更改。因此,不会触发AfterUpdate或CellChange,当您离开单元格时,它将恢复为空白。如何使AutoComplete工作并仍然将零值显示为空白?这是我的代码(注意,如果你注释掉设置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

2 个答案:

答案 0 :(得分:1)

您需要将AutoCompleteMode设置为网格列,而不是Ultracombo。当UltraCombo设置为EditorComponent时,网格使用其编辑器。如果在这种情况下将AutoCompleteMode设置为组合,则它对网格没有任何影响。 如果将AutoCompleteMode设置为网格列,则不需要将DataFilter设置为组合。

答案 1 :(得分:0)

原来这是Infragistics 11.2中的一个错误。我不确定他们在什么时候修复它,但15.2版本不会发生这种情况。