public void RefreshGameLB() { genreShowNum = GenreCB.SelectedIndex; GameLB.Items.Clear(); Cheats.Clear(); using (GCDBContext _dbc = new GCDBContext(ConString)) { IQueryable <Cheat> req; if (genreShowNum == 0) { req = from VAR in _dbc.Cheats select VAR; } else { req = from VAR in _dbc.Cheats where VAR.Genre == genreShowNum select VAR; } foreach (var cheat in req) { Cheats.Add(cheat); } foreach (var cheat in Cheats) { GameLB.Items.Add(cheat.GameName); } if (GameLB.Items.Count > 0) { GameLB.SelectedIndex = 0; } } }