4
我想從BindingSource過濾數據 - 但它不工作。 我在做什麼錯? 我已經將我的代碼簡化爲一個簡約的例子。datagridview綁定源過濾器
問題是,如果我在文本框中鍵入內容 - 沒有任何反應。
public partial class Form1 : Form
{
BindingSource bs = new BindingSource();
public Form1()
{
InitializeComponent();
List<myObj> myObjList= new List<myObj>();
myObjList.Add(new myObj("LastNameA", "Peter"));
myObjList.Add(new myObj("LastNameA", "Klaus"));
myObjList.Add(new myObj("LastNameB", "Peter"));
foreach (myObj obj in myObjList)
{
bs.Add(obj);
}
dataGridView1.DataSource = bs;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
bs.Filter = string.Format("Name LIKE '%{0}%'", textBox1.Text);
dataGridView1.Refresh();
}
}
public class myObj
{
public myObj(string LastName, String Name)
{
this.LastName = LastName;
this.Name = Name;
}
public string LastName { get; set; }
public string Name { get; set; }
}
我已閱讀MSDN文檔現在已經應用了BindingList。 但是,如果我在文本框中的typ字母 - 沒有任何反應 – Blindsurfer
'BindingList'不會實現'IBindingListView'。 –
NathanAldenSr