'Is there a way to display ampersand ("&") inside a windows form MetroComboBox (C#)?

I created a form within the Metro Framework in which I have a MetroComboBox made of strings which are taken from a list. Each time the user selects an option from the defined MetroComboBox, the selected string is the printed in a textbox. I have the need to display the ampersand (&) symbol inside my MetroComboBox and inside the textbox. However, now it is underlining all the characters which are following it. I already tried to replace the single ampersand with a double ampersand, but this solves the problem only inside the comboBox, where I managed to obtain a single &, but this also results in two ampersands (&&) being printed in the text box.

        private void Form1_Load(object sender, EventArgs e)
        {

            string[] vacc = { "J&J", "Luke", "Ben",  "Kat"};
            List<string> elements = new List<string>();
            
            foreach (string element in vacc)
            {
                if (element.Contains("&"))
                {
                    elements.Add(element.Replace("&", "&&"));
                }
                else
                {
                    elements.Add(element);
                }
            }

            metroComboBox1.DataSource = elements;
            this.Controls.Add(metroComboBox1);
            this.metroComboBox1.SelectedIndexChanged += new System.EventHandler(metroComboBox1_SelectedIndexChanged);

        } 

Form Output before replacement

Form Output after replacement

I am also aware about the following option

label.UseMnemonic = false;

However, I was not able to find an equivalent property to be applied in case of MetroComboBoxes. Any help will be greatly appreciated. Thanks in advance!!



Solution 1:[1]

EDIT

The code is not much different than yours but gets the outcome you expect.

I can't see what your selection changed code looks like so I wrote my own.

    private void Form1_Load(object sender, EventArgs e)
    {
        string[] vacc = { "J&J", "Luke", "Ben", "Kat" };
        List<string> elements = new List<string>();

        foreach (string element in vacc)
        {
            if (element.Contains("&"))
            {
                elements.Add(element.Replace("&", "&&"));
            }
            else
            {
                elements.Add(element);
            }
        }

        metroComboBox1.DataSource = elements;
        this.Controls.Add(metroComboBox1);
        this.metroComboBox1.SelectedIndexChanged += MetroComboBox1_SelectedIndexChanged;

    }

    private void MetroComboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        metroLabel1.UseMnemonic = false;
        metroLabel1.Text = (string)metroComboBox1.SelectedValue;
    }

Image showing the outcome:

Working as expected

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1