【发布时间】:2015-04-29 16:30:00
【问题描述】:
我试图在选择组合框中的项目后获取 DepartmentId,然后将其分配给 nameTextBox.Text。但是当我运行程序时,它给出了空引用异常。
var deptList = dr.ReadAllDepartment();
departmentCombobox.DisplayMemberPath = "DepartmentName";
departmentCombobox.SelectedValuePath = "DepartmentId";
departmentCombobox.ItemsSource = deptList;
nameTextBox.Text = departmentCombobox.SelectedValue.ToString();
【问题讨论】:
-
您可以使用 SetValues。 stackoverflow.com/questions/5807622/…
标签: c# wpf entity-framework