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
2010-05-23 19:15:04
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ı
2010-05-23 19:42:48
What on earth do you mean? Please show your code.
SLaks
2010-05-23 19:46:21
Ok I found my error,thank you for your help
aslı
2010-05-23 19:59:38