private void PopulateEncodings(string startupEncoder) { var encodings = new SupportedEncodings(); IEnumerable <EncodingItem> list = encodings.GetEncoderList(); foreach (EncodingItem item in list) { lstEncoding.Items.Add(item); } if (encodings.IsValidName(startupEncoder)) { EncodingItem x = encodings.GetItem(startupEncoder); lstEncoding.SelectedItem = x; } else { lstEncoding.SelectedIndex = 0; } }