我是Windows新手。我想在windows c#中的combobox中更改索引上的选定项目,在页面加载时调用selectedindexchanged事件。怎么回事。所以请帮助我。
提前致谢
答案 0 :(得分:1)
这是一个简单的例子:
int selectedIndex = comboBox1.SelectedIndex;
Object selectedItem = comboBox1.SelectedItem;
MessageBox.Show("Selected Item Text: " + selectedItem.ToString() + "\n" +
"Index: " + selectedIndex.ToString());
答案 1 :(得分:1)
假设您在SelectedIndexChanged事件中:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("Selected Item Text: " + comboBox1.SelectedItem.ToString() + "\n" +
"Index: " + comboBox1.SelectedIndex.ToString());
}