开发者

combobox inserting consecutive variables

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜