我有以下应用程序代码:
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({0, ""})
datatableCombo.Rows.Add({1, "123"})
datatableCombo.Rows.Add({2, "234"})
datatableCombo.Rows.Add({3, "456"})
UltraCombo1.DataSource = datatableCombo
Dim datatableGrid = New DataTable
datatableGrid.Columns.Add("ID", GetType(Integer))
datatableGrid.Columns.Add("Name", GetType(String))
SsiGrid1.DataSource = datatableGrid
SsiGrid1.DisplayLayout.GroupByBox.Hidden = True
SsiGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True
SsiGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom
SsiGrid1.DisplayLayout.Bands(0).Columns("ID").EditorComponent = UltraCombo1
SsiGrid1.DisplayLayout.Bands(0).Columns("ID").CellClickAction = CellClickAction.EditAndSelectText
SsiGrid1.DisplayLayout.Bands(0).Columns("ID").Style = ColumnStyle.DropDownValidate
End Sub
Private Sub UltraCombo1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraCombo1.InitializeLayout
UltraCombo1.ValueMember = "ID"
UltraCombo1.DisplayMember = "Name"
Dim band As UltraGridBand = Me.UltraCombo1.DisplayLayout.Bands(0)
Dim position As Integer = 0
band.Columns("ID").Hidden = False
band.Columns("ID").Header.VisiblePosition = position
position += 1
band.Columns("Name").Hidden = False
band.Columns("Name").Header.VisiblePosition = position
position += 1
band.Override.AllowRowFiltering = DefaultableBoolean.False
band.Override.RowFilterMode = RowFilterMode.AllRowsInBand
band.ColumnFilters("ID").FilterConditions.Clear()
band.ColumnFilters("ID").FilterConditions.Add(FilterComparisionOperator.NotEquals, 0)
End Sub
End Class
我认为这应该使得组合框不会显示零行,除非您实际键入零。但是当我运行它时,它确实显示零行。我的代码有问题吗?
答案 0 :(得分:1)
你是对的。此代码应隐藏下拉列表中的零。出现此错误的一个可能原因可能是您实际上没有处理组合的InitializeLayout事件。您可以通过打开设计器轻松检查这一点,如果针对InitializeLayout事件选择了UltraCombo1_InitializeLayout,则选择组合并检入属性窗口。 您还可以在事件处理程序中的某处放置断点,看看是否到达它。