我正在尝试获得一个组合框下拉列表,允许用户键入组合框以过滤下拉列表,但强制用户必须选择其中一个可用选项,而不能只输入他们想要的内容。我有下面的代码和
comboBoxProperties.DropDownStyle = DropDownStyle.DropDownList;
行应该只允许用户选择一个可用的选项,但我仍然能够输入我想要的任何内容并点击选项卡,该字段只保留我输入的内容。
USStateCollection states = new USStateCollection();
states.LoadAll();
states.Filter = states.AsQueryable().OrderBy(d => d.StateName);
settings.Columns.Add(c =>
{
c.Caption = "State";
c.FieldName = "State";
c.Width = Unit.Percentage(10);
c.Settings.FilterMode = ColumnFilterMode.Value;
c.ColumnType = MVCxGridViewColumnType.ComboBox;
var comboBoxProperties = c.PropertiesEdit as ComboBoxProperties;
comboBoxProperties.DataSource = states;
comboBoxProperties.TextField = "StateName";
comboBoxProperties.ValueField = "StateAbbrev";
comboBoxProperties.ValueType = typeof(System.String);
comboBoxProperties.DropDownStyle = DropDownStyle.DropDownList;
comboBoxProperties.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
});