C# 如何从组合框c中只获取第一个索引#
我的组合框上有两个索引 我只想取第一个索引 我能举个例子吗 守则:C# 如何从组合框c中只获取第一个索引#,c#,windows,visual-studio,windows-forms-designer,C#,Windows,Visual Studio,Windows Forms Designer,我的组合框上有两个索引 我只想取第一个索引 我能举个例子吗 守则: foreach (DataRow dr2 in dt2.Rows) { comboBox1.Items.Add(dr2["Station"].ToString() + " - " + dr2["Ime"].ToString()); } 我想使用dr2[“Stat
foreach (DataRow dr2 in dt2.Rows)
{
comboBox1.Items.Add(dr2["Station"].ToString() + " - " + dr2["Ime"].ToString());
}
我想使用
dr2[“Station”]。ToString()
?Win Forms组合框既有SelectedIndex
又有SelectedText
属性
在列表中加载项目后,您可以选择如下所示的选项:
// selected by position in the list
comboBox1.SelectedIndex = 0;
// ... by value
comboBox1.SelectedText = "some value";