title: How to make a textbox in c# winform to accept auto suggestions not only from starting but also from middle or any place if matching
body: <p>I have a simple form with a textBox in it which I am trying to make an user friendly Auto-suggest Textbox..</p>
  
  <p>As per the current scenario I am using <code>AutoCompleteStringCollection</code>class bywhich I am able to make textbox show suggestions for the word that starts with the particular Text entered in textbox..
  But,I want to make my program as like it should show suggestions even when a part of the string coming from database matches the Textbox.Text.</p>
  
  <p>Presently I am able to filter the data coming from DB based on the userInput by using <code>dataView</code> .But still I am not able to show output on my front end..</p>
  
  <p>I have tried all textbox events like '<code>KeyPress</code>',<code>KeyDown</code>,<code>KeyUp</code>,<code>TextChanged</code> but its not working....</p>
  
  <p>MyCode::</p>
  
  <pre><code>         public partial class Form2 : Form
          {
              AutoCompleteStringCollection autoCompletefromDB = new AutoCompleteStringCollection();
              AutoCompleteStringCollection searchResults = new AutoCompleteStringCollection();
  
  
              MyLinqDataContext dtcontext = new MyLinqDataContext();
            //  static string searchChar = "";
              SqlConnection con = new SqlConnection("Data Source=DATASERVER\\SQL2K8;Initial Catalog=VTMMedicalContent;Persist Security Info=True;User ID=vtm;Password=M3d!c@l");
              DataTable dTable = new DataTable();
              SqlCommand cmd;
              SqlDataAdapter da;
              DataView dtView;
              public Form2()
              {
                  InitializeComponent();
              }
  
              private void Form2_Load(object sender, EventArgs e)
              {
                  cmd = new SqlCommand();
                  cmd.Connection = con;
                  cmd.CommandType = CommandType.Text;
                  cmd.CommandText = "select DiagnosisName from [VTMMedicalContent].[dbo].[DiagnosisMaster]";
                  da = new SqlDataAdapter(cmd);
                  da.Fill(dTable);
                  dtView = new DataView(dTable);
  
              }
  
       //And My KeyPress Event Code..
  
   private void txtAutoComplete_KeyPress(object sender, KeyPressEventArgs e)
          {
              if (!Char.IsControl(e.KeyChar))
              {
                  dtView.RowFilter = dtView.Table.Columns[0].ColumnName + " Like '%" + e.KeyChar + "%'";
                  foreach (DataRowView dtViewRow in dtView)
                      searchResults.Add(dtViewRow[0].ToString());
  
                  txtAutoComplete.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                  txtAutoComplete.AutoCompleteSource = AutoCompleteSource.CustomSource;
                  txtAutoComplete.AutoCompleteCustomSource = searchResults;
              }
              //MessageBox.Show("The Elements in searchResult are:" + searchResults.Count);
          }
  </code></pre>
  
  <p>I have the tried writing the same codes in <code>KeyDown</code>,<code>KeyUp</code>,<code>TextChanged</code> events but of no use..:(</p>
  
  <p>It only works on Form_Load but that only shows suggestions that matches the starting point of the word..</p>