c#中如何实现combobox和文本框的关联

2024-11-05 02:39:01
推荐回答(1个)
回答1:

 private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Add("aaa");
            comboBox1.Items.Add("bbb");
            comboBox1.Items.Add("ccc");
            comboBox1.Items.Add("ddd");

            

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox1.Text = comboBox1.SelectedItem.ToString();
        }