Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

regex - How to keep only specific item at Combobox

I'm newbie here, and new to programing c#.

I am using Microsoft c#.

I want to know how to keep only specific item at Combobox when click on button1.

That item is a random word that was loaded automaticaly to the combobox1, but will contain "-test" word.

enter image description here

For example in this picture i just want to keep the list that contains "-test" word only in ouput combobox2 when click on button1.

To become like this

enter image description here

question from:https://stackoverflow.com/questions/65517150/how-to-keep-only-specific-item-at-combobox

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

i use this basic code but don't work

  private void button1_Click(object sender, EventArgs e)
    {




        var removeword = comboBox1.Items.Contains("test");
        if (comboBox1.Items.Contains("test") == true)
           
        }

            else
            {
            comboBox1.Items.Remove(removeword);
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...