simple & drop-down combo/list box questions

  • Thread starter Thread starter Tim923
  • Start date Start date
T

Tim923

Can someone tell me where in Properties to change a combobox/list from
simple to drop-down? I had it set to drop-down and couldn't remember
how to switch it back to simple. I don't know if it's being hidden.

The drop down listbox is named yachtLengthListBox, which should have
the list of 7 numbers already declared as constants, so I shouldn't
use the collection to enter them.

So I tried to use the statement
yachtLengthListBox.Items.Add(intLENGTH1.ToString());
but it came up with an error. Am I allowed to put that code right
after the class-level variable declarations, and must I change some
property in yachtLengthListBox to do so?
 
Hello Tim923,

How did you declare 7 numbers in constants? I'd use Enum or array int[] Numbers
= {1, 2, 3, 4, 5, 6, 7};

And you can't write code like yachtLengthListBox.Items.Add(intLENGTH1.ToString());
at class level... You should have it on Form_Load or in its constructor.
So I'd do like this.

private int[] _Numbers = {1, 2, 3, 4, 5, 6, 7};
private void Form1_Load(object sender, System.EventArgs e)
{
foreach(int i in _Numbers)
comboBox1.Items.Add(i);
}

So about simple to dropdown... You're gonna figure that out yourself... Just
look into property window more carefully.
 
Back
Top