开发者

ComboBox filling

I have a problem filling my ComboxBox. Here´s my code:

string[] test = { "Ausgaben", "Eingaben" };
foreach (string r in test)
{
   cbEinAus.Items.Add(r);
}

The values from the string array are in the ComboBox, but the sele开发者_如何转开发cted item is a empty string. I want one of this two string from the array to be my selected item.

I already tried with the SelectedItem property, but that doesn´t work.

Maybe its a simple solution... Can anybody help me please?


Use:

cbEinAus.SelectedIndex = 0;

You can replace the 0 with the zero based index of whichever item you want to select.


Try

cbEinAus.Items[vbEinAus.SelectedIndex]

instead of SelectedItem. usually works for me.


Try setting the SelectedItem as cbEinAus.Items[0]


You can set the Text property.

cbEinAus.Text = test[0];

More examples can be found at How do I set the selected item in a comboBox to match my string?


cbEinAus.SelectedIndex = 0;

replace item to index

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜