private void btnRemoveTile_Click(object sender, EventArgs e) { //If there's a tile set selected. if (cboTiles.SelectedIndex >= 0) { //Put the current index in a buffer. int Index = cboTiles.SelectedIndex; Helper.RemoveTileset(Index); //Move the current tile set. cboTiles.Items.RemoveAt(Index); TerrainAttribute.ListTileset.RemoveAt(Index); //Replace the index with a new one. if (cboTiles.Items.Count > 0) { if (Index >= cboTiles.Items.Count) { cboTiles.SelectedIndex = cboTiles.Items.Count - 1; } else { cboTiles.SelectedIndex = Index; } } else { cboTiles.Text = ""; } } }