5 Replies - 1405 Views - Last Post: 18 February 2012 - 09:58 AM Rate Topic: -----

#1 StickHerHappy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 15-January 12

The selected item in combobox didn't show up

Posted 18 February 2012 - 02:51 AM

       private void comboBox1_SelectedIndexChanged(object sender, EventArgs e){
            if (radioButton1.Checked == true) {
                string[] movies = System.IO.File.ReadAllLines(@"path");
                comboBox1.Items.Clear();
                foreach (string movie in movies )
                {
                    comboBox1.Items.Add(movie);
                    }
            }

            else if (radioButton2.Checked == true) {
                string[] movies = System.IO.File.ReadAllLines(@"path");
                comboBox1.Items.Clear();
                foreach (string movie in movies)
                {
                    
                    comboBox1.Items.Add(movie);
                }
            }

        }


good day sir, I have two radio button here, if I selected radioButton1.. I read a file that in a textfile. same thing with radio radioButton2(), the problem is when I clear the Items of previous entry.. it cleared but when I click the item it didn't show up in combobox can you help me :D tnx I appreciate it

Is This A Good Question/Topic? 0
  • +

Replies To: The selected item in combobox didn't show up

#2 Momerath   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1021
  • View blog
  • Posts: 2,463
  • Joined: 04-October 09

Re: The selected item in combobox didn't show up

Posted 18 February 2012 - 03:10 AM

I'm not sure what you mean when you say "when I click the item it didn't show up". It it isn't there, how can you click it?

Also, unless I'm missing something, those two code blocks are identical. Why don't you just combine them and get rid of the radio buttons?

And I'm sure tlhIn`toq will be along to comment on your control names :)
Was This Post Helpful? 0
  • +
  • -

#3 StickHerHappy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 15-January 12

Re: The selected item in combobox didn't show up

Posted 18 February 2012 - 03:30 AM

sir, if I removed the "comboBox1.Items.Clear();" and select an item in combo box it show up but, if I put "comboBox1.Items.Clear();" to clear previous item entries .. it cleared but when I select a to the new item entries it didn't show up in combo box, same thing in other one :D

*select a Item to the new item entries it didn't show up in combo box, same thing in other one

sorry for typo
Was This Post Helpful? 0
  • +
  • -

#4 Momerath   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1021
  • View blog
  • Posts: 2,463
  • Joined: 04-October 09

Re: The selected item in combobox didn't show up

Posted 18 February 2012 - 03:55 AM

Still not getting it. Let's say you have this in the combo box:

Line 1
Line 2
Line 3

You select 'Line 2' with the first radio button checked. New items show up in the combo box

Item 1
Item 2
Item 3

You select 'Item 1' and what happens? What did you expect to happen?
Was This Post Helpful? 0
  • +
  • -

#5 StickHerHappy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 15-January 12

Re: The selected item in combobox didn't show up

Posted 18 February 2012 - 04:04 AM

sir.. this is the main problem.. if I use the "comboBox1.Items.Clear();" in the code and let say for example I have this items in my combobox:

apple
orange
banana

and click apple.. then in normal way the combobox will show it but in my case it's displaying blank after you click it.. :D I hope you get it sir
Was This Post Helpful? 0
  • +
  • -

#6 Momerath   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1021
  • View blog
  • Posts: 2,463
  • Joined: 04-October 09

Re: The selected item in combobox didn't show up

Posted 18 February 2012 - 09:58 AM

Of course it does, that's what the Clear() method is supposed to do. Why don't you explain what you want to have happen, with examples, and maybe we can help you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1