private void TbSearch_TextChanged(object sender, EventArgs e) { //Get the keywords from the search box string keywords = tbSearch.Text; //Check if the keyword has value if (keywords != null) { //Show user based on keyword DataTable dt = d.SearchM(keywords); dgvAdduser.DataSource = dt; } else { //Show all users in database DataTable dt = d.SelectM(); dgvAdduser.DataSource = dt; } }