-1
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
SqlConnection con = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SARManagement;Data Source=AIZAZ\SQLEXPRESS");
con.Open();
string query = "Select Semester,ID FROM Batch";
SqlCommand da = con.CreateCommand();
da.CommandText = query;
SqlDataAdapter adapter = new SqlDataAdapter(da);
DataSet ds = new DataSet();
adapter.Fill(ds, "Batch");
Semester.ItemsSource = ds.Tables[0].DefaultView;
Semester.DisplayMemberPath = ds.Tables[0].Columns["Semester"].ToString();
Semester.SelectedValuePath = ds.Tables[0].Columns["ID"].ToString();
}
catch (Exception ex)
{
MessageBox.Show("" + ex);
}
}
private void Semester_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
here how can i get combobox items.. that are listed in combobox as displaymemberpath
}
如何獲取這是從數據庫中檢索作爲組合框的DisplayMemberPath ...物品或分享另一種方式來檢索數據和插入數據作爲一個ListBoxItemC#WPF - 我怎樣才能獲得上市項目(組合框)
你嘗試過什麼嗎?什麼殘害你?你有沒有找過類似的解決方案? –
是的,我試過每一件事......但沒有任何解決方案來獲取列出的項目.. –
或分享另一種方式列表數據作爲ListBoxItem在組合框.. –