从WPFcombobox中获取选定项目,该combobox由来自访问数据库的数据填充
我有一个combobox使用下面的代码从访问数据库的数据填充 public void BindComboBox(ComboBox ComboBoxOrg) { con.Open(); orgload = new OleDbCommand("SELECT organization_id, short_name FROM organization", con); OleDbDataAdapter da = new OleDbDataAdapter(); da.SelectCommand = orgload; DataSet ds = new DataSet(); da.Fill(ds); ComboBoxOrg.ItemsSource = ds.Tables[0].DefaultView; ComboBoxOrg.DisplayMemberPath = ds.Tables[0].Columns["short_name"].ToString(); ComboBoxOrg.SelectedValuePath = ds.Tables[0].Columns["organization_id"].ToString(); con.Close(); } XAML UI代码是 <ComboBox x:Name="ComboBoxOrg" Width="308" Height="40" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="18" Margin="0,0,0,100" Foreground="#FF666666" ItemsSource="{Binding}"/> 我想获得select的项目,然后用它来查询一个表(用户),其中的id是存在的例如。 OleDbConnection […]