Hi,
I want to make a searchbox in my windows form but I'm having an exception error
I wish someone will help me fix this
I have a code in my textbox
private void textBox1_TextChanged(object sender, EventArgs e)
{
DataTable clone = dt.Clone();
foreach (DataRow dr in dt.Select("Name" + textBox1.Text + "%'"))
{
clone.ImportRow(dr);
}
IsBound = false;
listBox1.DataSource = clone;
listBox1.DisplayMember = "Name";
listBox1.ValueMember = "Tag";
IsBound = true;
}and this is the code from listbox
private void BindCurrentList()
{
Word.Application App = Globals.ThisAddIn.Application;
Word.Document doc = App.ActiveDocument;
Word.Sources sour = doc.Bibliography.Sources;
string[] strItems = new string[sour.Count];
for (int i = 1; i <= sour.Count; i++)
{
Word.Source ssour = sour[i];
string tag = ssour.Tag;
if (ssour.XML.IndexOf("<b:Author>") >= 0)
{
strItems[i - 1] += ssour.Field["Author"] + ";";
}
if (ssour.XML.IndexOf("<b:Title>") >= 0)
{
strItems[i - 1] += ssour.Field["Title"];
}
if (ssour.XML.IndexOf("<b:Year>") >= 0)
{
strItems[i - 1] += "(" + ssour.Field["Year"] + ")";
}
listBox1.DisplayMember = "Name";
listBox1.ValueMember = "Tag";
listBox1.Items.Add(new Tagg(strItems[i - 1], tag));
}
}I want that if I input any letter in the textbox ,the item in the listbox will change according to what I put in the textbox.
by the way this code triggers the exception code.
foreach (DataRow dr in dt.Select("Name" + textBox1.Text + "%'"))help me pls
thank you in advance
more power and
god bless us all.