private void textBox1_TextChanged(object sender, EventArgs e) { //只要文本框的内容改变这个事件就会被触发 //获取文本框的内容 ProductInfoBLL bll = new ProductInfoBLL(); if (string.IsNullOrEmpty(txtSearch.Text)) { LoadProductInfoByDelFlag(0); } else { if (bll.GetProductByProNum(txtSearch.Text).Count == 0) { } else { dgvProductInfo.AutoGenerateColumns = false; dgvProductInfo.DataSource = bll.GetProductByProNum(txtSearch.Text); dgvProductInfo.SelectedRows[0].Selected = false; } } }
//模糊搜索 private void txtSearch_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtSearch.Text)) { ProductInfoBLL bll = new ProductInfoBLL(); dgvProductInfo.AutoGenerateColumns = false; dgvProductInfo.DataSource = bll.GetProductByProNum(txtSearch.Text); // dgvProductInfo.SelectedRows[0].Selected = false; // dgvProductInfo.AreAllCellsSelected(true); } else { LoadProductInfoByDelFlag(0); } }