private void ButtonSearchProduct_Click(object sender, EventArgs e) { if (TextBoxSearchProduct.Text == "") { MessageBox.Show("Please enter the name of the product to be searched."); } else { string x = TextBoxSearchProduct.Text; int count = 0; for (int j = 0; j < Inventory.MyProductList.Count; j++) { if (Inventory.MyProductList[j].Name.Equals(x)) { DataGridViewProduct.ClearSelection(); DataGridViewProduct.Rows[j].Selected = true; count++; } } if (count < 1) { MessageBox.Show("Product Name not found exactly as searched.(Case Sensitive)"); } // if (dataGridView.Rows[i].Cells[j].Value.ToString().Contains(searchText) //{ // dataGridView.Rows[i].Cells[j].Selected = true; // } } }
//Update display dgv with the current list private void Display() { DataGridViewPart.AutoGenerateColumns = false; DataGridViewProduct.AutoGenerateColumns = false; DataGridViewPart.DataSource = Inventory.MyPartList; DataGridViewProduct.DataSource = Inventory.MyProductList; DataGridViewPart.ClearSelection(); DataGridViewProduct.ClearSelection(); }