Hi, I am developing a WPF dictionary app. I have a listbox and a text box in my XAML code, based on the user input in the text box the Dataset must get filtered and the list box must only show the relevant rows. For example: if the user types in the 't' in the text box the listbox must only show words like 'television My problem is that when the form loads the listbox gets filled with 50 words, but when I type anything in the text box, the listbox becomes blank. I have tried filtering the Dataset itself using , but always getting errors can someone help me? How can I do that?
my code is here
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.OleDb;
using System.ComponentModel;
namespace DictionaryM
{
/// <summary>
/// Interaction logic for Dictionary.xaml
/// </summary>
public partial class Dictionary : Window
{
public ICollectionView view;
public Dictionary()
{
InitializeComponent();
BindData();
}
public void BindData()
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\CellBiology.mdb;Persist Security Info=True");
con.Open();
string sql = "Select Word from Dictionary";
OleDbCommand cmd = new OleDbCommand(sql, con);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
try
{
da.Fill(ds, "Word");
listBox1.DataContext = ds;
}
catch (Exception ex)
{
label1.Content = ex.Message;
}
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
// i dont know what will i code here?
}
}
thanks everyone who response this question