当Datagrid的选定值更改时,更改组合框的选定值 [英] Changing the Selected Value Of the ComboBox when Selected value of Datagrid Changed

查看:73
本文介绍了当Datagrid的选定值更改时,更改组合框的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ComboBox和数据网格,我将ComboBox绑定了,这是可以的,数据网格可以解决这个问题,当数据网格中的选定项发生更改时,我尝试更改Combobox的Selected值,这是

i have a ComboBox and data grid i binding the ComboBox and It is ok and data grid to the issue is i am try to change the Selected value of the Combobox when the selected item in data grid changed and this is the

private void DGV_Medecines_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
   Cls_MedecationController Med=new Cls_MedecationController();
   DataTable dt = new DataTable();
   try
   {
      dt = ((DataRowView)this.DGV_Medecines.SelectedItem).DataView.ToTable();                
      this.cmx_Arab.Text = Med.Get_ArabName(dt.Rows[this.DGV_Medecines.SelectedIndex]["Name_latin"].ToString());
   }
   catch
   {
   }
}



这是CMX绑定的鳕鱼



this is the cod of CMX Binding

DataTable dt = new DataTable();
            this.FacadeMed = new Cls_MedecationController();
            dt = this.FacadeMed.SellectAllMed();
            //this.cmx_Arab.ItemsSource = dt.DefaultView;
            this.Cmx_Latin.ItemsSource = dt.DefaultView;   

推荐答案

尝试设置this.cmx_Arab.SelectedValue属性而不是this.cmx_Arab.Text


这篇关于当Datagrid的选定值更改时,更改组合框的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆