当我键入第一个字母时,comboBox选择列表中的项目 [英] comboBox selecting items in the list when i type the first letter
本文介绍了当我键入第一个字母时,comboBox选择列表中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
comboBox
当我输入第一个字母时选择列表中的项目
comboBox selecting items in the list when i type the first letter
推荐答案
您好,
我做的很简单:
<ComboBox IsTextSearchEnabled="False" IsEditable="True" Height="23" HorizontalAlignment="Left" Margin="12,23,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" KeyUp="comboBox1_KeyUp" />
List<string> data=new List<string>();
public Window4()
{
InitializeComponent();
data.Add("Cherry1");
data.Add("Cherry2");
data.Add("Cherry3");
data.Add("Mattew1");
data.Add("Mattew2");
data.Add("Mattew3");
data.Add("Barry");
data.Add("Barry1");
this.DataContext = data;
comboBox1.ItemsSource = data;
}
private void comboBox1_KeyUp(object sender, KeyEventArgs e)
{
List<string> mylist = new List<string>();
mylist = data.FindAll(delegate (string s) { return s.ToLower().Contains(comboBox1.Text.ToLower().Trim()); });
comboBox1.ItemsSource = mylist;
comboBox1.IsDropDownOpen = true;
}
如果您想通过输入来过滤组合框,您可以查看以下文章:
If you want to filter comboboxitem by entering, you can take a look the following article:
http://arkeshkorat.blogspot.sg/2013/ 05 / auto-complete-combobox-in-wpf.html
这是一个简单的样本,您也可以参加看:
Here is the simple sample that you can also take a look:
https://stackoverflow.com/questions/34382459 / simple-wpf-combobox-filter
最好的问候,
Cherry < a href ="https://stackoverflow.com/questions/34382459/simple-wpf-combobox-filter">
这篇关于当我键入第一个字母时,comboBox选择列表中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文