locked
Show members of combo box when radio button clicked? RRS feed

  • Question

  • I have a combo box filled with 10 items. And a radio button on the form.

    When the radio button is clicked, I want the combo box to open and display the items as if the drop down arrow had been clicked.

    Anyone know what event activates that drop down arrow click?

    I then want to be able to select an item directly from that list.

    Any suggestions?

    Thanks!


    jdballou

    Wednesday, November 25, 2015 5:22 PM

Answers

  • I'm not clear whether the click of the user selects the item.

    Ignore the selectedindex line if it's the user.

    I have an experimental form with a radiobutton and a combo on it.

        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                BindingSource bs = new BindingSource();
                bs.DataSource = new List<string> { "aaaaa", "bbbb", "cccc" };
                comboBox1.DataSource = bs;
            }
    
            private void radioButton1_Click(object sender, EventArgs e)
            {
                comboBox1.DroppedDown = true;
                comboBox1.SelectedIndex = 1;
            }

    The line

    comboBox1.DroppedDown = true;

    Drops down the combo and the line after selects an entry.

    You might want to go with checkedchange and see if it's checked rather than click, depending on your requirement.


    Hope that helps.

    Technet articles: WPF: MVVM Step 1; All my Technet Articles

    Wednesday, November 25, 2015 6:59 PM