lunaclover
Programmer
- Jun 22, 2005
- 54
Hi - my code is filled with "if then else" statements in it, as the program I'm writing has many exceptions and combinations of selections between radiobuttons, textboxes and comboboxes. I have a combobox that I want to empty its contents from a previous selection, and refill with new contents.
For example, part of my code reads..
If rb1.checked then
If rb2.Checked Then
cb1.Items.Add("1.5")
cb1.Items.Add("2.0")
cb1.Items.Add("2.5")
cb1.Items.Add("3.0")
.
.
.
If rb3.Checked Then
cb1.Items.Add("2.5")
cb1.Items.Add("3.5")
cb1.Items.Add("4")
cb1.Items.Add("5")
and so on for about 9 different scenerios, (with more nested if statments inside(where the ... are)).
When running the program and selections are made and changed, the combo box items are added each time so it just adds the items over and over again, so they are all listed x number of times. When I used the cb1.items.clear() in each nested if statement, it works, and you can pull the drop-down menu down and see the options specific to that scenerio, but when you select one and the drop-down list closes, the selection doesn't stay in the box. It just goes empty. I have tried cb1.dispose(), cb1.refresh().. not sure what to do because clear() isn't letting me select anything when it's in the code.
To summarize - I am looking to find out which command I can use that will clear the contents of a combobox in order to fill it with the correct options depending on the combination of buttons a user may select. And be able to select it afterwards.
Thanks to anybody who can help. I am still very new and learning, so may have looked over something simple.
Luna
For example, part of my code reads..
If rb1.checked then
If rb2.Checked Then
cb1.Items.Add("1.5")
cb1.Items.Add("2.0")
cb1.Items.Add("2.5")
cb1.Items.Add("3.0")
.
.
.
If rb3.Checked Then
cb1.Items.Add("2.5")
cb1.Items.Add("3.5")
cb1.Items.Add("4")
cb1.Items.Add("5")
and so on for about 9 different scenerios, (with more nested if statments inside(where the ... are)).
When running the program and selections are made and changed, the combo box items are added each time so it just adds the items over and over again, so they are all listed x number of times. When I used the cb1.items.clear() in each nested if statement, it works, and you can pull the drop-down menu down and see the options specific to that scenerio, but when you select one and the drop-down list closes, the selection doesn't stay in the box. It just goes empty. I have tried cb1.dispose(), cb1.refresh().. not sure what to do because clear() isn't letting me select anything when it's in the code.
To summarize - I am looking to find out which command I can use that will clear the contents of a combobox in order to fill it with the correct options depending on the combination of buttons a user may select. And be able to select it afterwards.
Thanks to anybody who can help. I am still very new and learning, so may have looked over something simple.
Luna