private void ButtonSearchPart_Click(object sender, EventArgs e) { if (TextBoxSearchPart.Text == "") { MessageBox.Show("Please enter the name of the part to be searched."); } else { string x = TextBoxSearchPart.Text; int count = 0; for (int j = 0; j < Inventory.MyPartList.Count; j++) { if (Inventory.MyPartList[j].Name.Equals(x)) { DataGridViewPart.ClearSelection(); DataGridViewPart.Rows[j].Selected = true; count++; } } if (count < 1) { MessageBox.Show("Part 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(); }