wpf ComboBox控件DisplayMemberPath属性怎么绑定多值?从数据库绑定
1个回答
展开全部
ds = new DataSet();
DBHelper dbHelper = new DBHelper();
// 查询歌曲类型的Sql语句
string sql = "select * from song_type";
SqlDataAdapter adapter = new SqlDataAdapter(sql, dbHelper.Connection);
adapter.Fill(ds, "song_type");
// 绑定歌曲类型到下拉列表中
this.cboSongType.DataSource = ds.Tables["song_type"];
this.cboSongType.ValueMember = "songtype_id";
this.cboSongType.DisplayMember = "songtype_name";
DBHelper dbHelper = new DBHelper();
// 查询歌曲类型的Sql语句
string sql = "select * from song_type";
SqlDataAdapter adapter = new SqlDataAdapter(sql, dbHelper.Connection);
adapter.Fill(ds, "song_type");
// 绑定歌曲类型到下拉列表中
this.cboSongType.DataSource = ds.Tables["song_type"];
this.cboSongType.ValueMember = "songtype_id";
this.cboSongType.DisplayMember = "songtype_name";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询