This is how I am populating my combobox from database which is large quantity. How i am search from list items in combobox as suggested not start from beginning it search also substring found inside of the string. and show all matching results in suggested list of combobox
{
SqlConnection connection = DBConnectivity.getConnection();
SqlCommand command;
string query;
DataSet dataset;
DataTable datatable;
SqlDataAdapter adapter;
SqlDataReader reader;
string[] ProductNameList;
public productform()
{
InitializeComponent();
}
//------------Form load Events and functions-----------------------------
DataSet dataset2 = new DataSet();
ClassesAll.PartyandProductClass PartyandProducts = new ClassesAll.PartyandProductClass();
private void productform_Load(object sender, EventArgs e)
{
try
{
// events for loading partytype broker on load
string query2 = "SELECT productNameUR, id FROM product";
SqlCommand command2 = DBConnectivity.getCommandForQuery(query2, connection);
SqlDataAdapter adapter2 = new SqlDataAdapter(command2);
adapter2.Fill(dataset2);
int result = command2.ExecuteNonQuery();
this.cBjins.DisplayMember = "productNameUR";
this.cBjins.ValueMember = "id";
DataRow datarow1 = dataset2.Tables[0].NewRow();
datarow1["productNameUR"] = "Select Product";
dataset2.Tables[0].Rows.InsertAt(datarow1, 0);
this.cBjins.DataSource = dataset2.Tables[0];
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Suggest me a solution.