这就是我从大量数据库中填充组合框的方法。 我如何从组合框中的列表项搜索,因为建议不从头开始搜索也找到字符串内部的子字符串。并在建议的组合框列表中显示所有匹配的结果
{
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);
}
建议我一个解决方案。