I have a question about combobox.I use visual c# and I want to insert consecutive numbers (1 to 100) in 开发者_JS百科combobox.How can I do this?
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();
精彩评论