Durga Velusamy

Durga Velusamy

  • NA
  • 318
  • 113.7k

different ways of using combobox

Mar 25 2015 5:18 AM
in my application i have combobox to list in that it shows all list . so i want  the to be extracted
like in mobile we search name in that just we give 1st letter it shows those name starts with the 1st letter. how to give this concept in windows form . i know this in database but i want  in windows form. anyone pls give solution


the below code is it possible to runtime  i .e day to day  list of values will be increased?  

private void Form1_Load(object sender, EventArgs e)
  {
  ComboBox_Autocomplete();
  }

  private void ComboBox_Autocomplete()
  {
  comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
  comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;

  DataTable dt = new DataTable();
  dt.Columns.Add("value", typeof(int));
  dt.Columns.Add("Text", typeof(string));

  dt.Rows.Add(1, "Shanu");
  dt.Rows.Add(2, "raja");
  dt.Rows.Add(3, "Albert");
  dt.Rows.Add(4, "Afraz");
  dt.Rows.Add(5, "Aadam");
  dt.Rows.Add(6, "Mak");
  dt.Rows.Add(7, "madan");
  dt.Rows.Add(8, "test");
  dt.Rows.Add(9, "newtest");

  comboBox1.DataSource = dt;
  comboBox1.ValueMember = "value";
  comboBox1.DisplayMember = "Text";
  }


Answers (2)