我正在使用Telerik Raddropdownlist,并将自动完成模式设置为建议。当我在文本框中输入第一个字符时说“ 1”,该下拉菜单将建议所有以1开头的项目都可以(假设match1之后列出的前2个项目为1234和1456)。但是,当我键入另一个“ 1”时,文本框将附加“ 111234”,这基本上是我键入的1以及下拉列表中的第一个元素。尽管建议使用自动完成模式,而不建议使用appappend,但我不知道为什么要附加第一个匹配项。
this.radDropDownList1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
this.radDropDownList1.AutoSizeItems = true;
this.radDropDownList1.DefaultItemsCountInDropDown = 20;
this.radDropDownList1.DropDownHeight = 160;
this.radDropDownList1.DropDownMinSize = new System.Drawing.Size(400, 200);
this.radDropDownList1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F);
this.radDropDownList1.Location = new System.Drawing.Point(803, 23);
this.radDropDownList1.MaxDropDownItems = 10;
this.radDropDownList1.Name = "radDropDownList1";
this.radDropDownList1.RootElement.AutoSize = false;
this.radDropDownList1.Size = new System.Drawing.Size(280, 36);
this.radDropDownList1.TabIndex = 2;
this.radDropDownList1.Text = "Select Project";
this.radDropDownList1.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Font = new System.Drawing.Font("Microsoft Sans Serif", 16);
this.radDropDownList1.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(this.raddropdownlist_SelectedIndexChanged);
radDropDownList1.DataSource = ditems;
radDropDownList1.DisplayMember = "ProjectName";
radDropDownList1.ValueMember = "ProjectName";
radDropDownList1.AutoCompleteDataSource = ditems;
radDropDownList1.AutoCompleteMode = AutoCompleteMode.Suggest;
Size popupSize = new Size(400, 300);
radDropDownList1.DropDownListElement.AutoCompleteSuggest.DropDownList.DropDownMinSize = popupSize;
radDropDownList1.DropDownListElement.DropDownMinSize = popupSize;
radDropDownList1.ListElement.Font = new Font("Microsoft Sans Serif",16);
radDropDownList1.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Font = new System.Drawing.Font("Microsoft Sans Serif", 16);
}
catch (Exception ex)
{
Utils.LogManager.write("Exception occur While populating Projects. error detail: " + ex.Message + "\r\nStacktrace: " + ex.StackTrace, "error");
ExceptionDialog.ShowExceptionDialog(ex);
}
radDropDownList1.SelectedIndex = -1;
radDropDownList1.Text = "Select Project";
private void raddropdownlist_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
if (radDropDownList1.SelectedIndex >=0)
{
cbTaskList.Select();
PopulateTasks();
if (this.GetMainForm().IsResetApp)
{
return;
}
}
}
我知道我的代码中有很多冗余,但是我很难调整AutoSuggest弹出窗口的大小,并且对此我还是陌生的。
答案 0 :(得分:0)
radDropDownList1.DropDownListElement.AutoCompleteSuggest.DropDownList.Popup.Font = new System.Drawing.Font("Microsoft Sans Serif", 16);
导致其行为异常。一旦我将其注释掉,它就可以正常工作。