0

I am new to coding programs, please bear with me, I am making a delimiter and using a combobox to store my delimiters, i am using a blank space (" ") as a delimiter, the action works how i intended but when you open the combobox it shows a blank spot where the delimiter is, i want to keep the back code but just make is say "Space". ive searched high and low all yesterday and today before finally making an account here to ask for help, it might be a simple solution and im just not seeing it, any help is greatly appreciated. thanks in advance (keep in mind i want to add the new line code as a delimiter as well, i just left commented for the sake of trying to get a simpler answer, im sure whatever solution can be applied the same way to that code.

        //string NEW_LINE = Environment.NewLine;
        //metroComboBox1.Items.Add(NEW_LINE);
        string SPACE = " ";                    //<----working
        metroComboBox1.Items.Add(SPACE);       //<-----working






        metroComboBox1.DisplayMember = "Text";     
        metroComboBox1.ValueMember = "Value";
        // var items = new[]
        //{
        //    new {Text = ",",Value =","},
        //    new {Text = "Space",Value = " "},
        //    new { Text = "New Line", Value = Environment.NewLine },
        //    new { Text = "@", Value = "@" }
        //};
        ////(metroComboBox1.SelectedItem as dynamic).Value(null);
        //metroComboBox1.DataSource = items;

**Tried the above, showed the "Space text" but didnt set the results i wanted

below are some pictures of the above code, and results.. I also included my delim button code in case i did something wrong there where trying the included "Var methodd that iput the name there but messed up the code. thanks again for any help thrown my way.

code im using and commented code i tried

what i want worked but left the item blank in combobox

delim button that selects combobox items

DevSecLoki
  • 23
  • 3

1 Answers1

1

You can try like this, using Dictionary.

Dictionary<string, string>test = new Dictionary<string, string>();
    test.Add("Space", " ");
    test.Add("Comma", ",");
    test.Add("New Line", Environment.NewLine);
    comboBox1.DataSource = new BindingSource(test, null); //Assign the items to combobox
    comboBox1.DisplayMember = "Value";
    comboBox1.ValueMember = "Key";

Here is the source solution

jad
  • 138
  • 8