tags:

views:

18

answers:

1

Hi,I have a question about combobox.I use visual c# and I want to insert consecutive numbers (1 to 100) in combobox.How can I do this?

+1  A: 

You need to use a for loop, like this:

for (int i = 0; i < 100; i++) {
    comboBox.Items.Add(i + 1);
}

You can also use LINQ:

comboBox.DataSource = Enumerable.Range(1, 100).ToArray();
SLaks
I used the loop code .It worked first but then I deleted the variables written before by me, at that time it did not show the new inserted variables.
aslı
What on earth do you mean? Please show your code.
SLaks
Ok I found my error,thank you for your help
aslı