private void btnAddPair_Click(object sender, EventArgs e) { int newPID, newFreq; if (!int.TryParse(txtPID.Text, out newPID) || !int.TryParse(txtFreq.Text, out newFreq)) { MessageBox.Show("Please enter integer values for both Pokemon ID and Frequency of spawn."); return; } if (selected.Spawns.ContainsKey(newPID)) { MessageBox.Show("This spawn already contains that Pokemon ID. Pokemon IDs must be unique."); return; } if (!selected.AddSpawnPair(newPID, newFreq)) { MessageBox.Show("Error adding! Frequencies must not exceed 100 and Pokemon IDs must be unique."); return; } lbPairs.Items.Add(newPID + " : " + newFreq); lbPairs.SelectedIndex = lbPairs.Items.Count - 1; }