xml:
<ComboBox SelectionChanged="status_SelectionChanged" Height="23" Name="status" ItemsSource="{Binding}" Width="120">
</ComboBox>
如何将数据库中的项目添加为组合框的 ItemsSource?
MySqlCommand status_db = new MySqlCommand("select name from request_status", conn);
所以:
List<string> combolist = new List<string>();
MySqlDataReader reader = status_db.ExecuteReader();
while (reader.Read())
{
combolist.Add((string)reader);
}
但是错了……