回复 3楼zhuxialiang的帖子
3# 中的 DataGridComboBoxColumn 数据绑定有问题,Demo 中绑定了整个表单,请着重参考:
- private void grid_AutoGeneratingColumn(object sender, C1.WPF.DataGrid.DataGridAutoGeneratingColumnEventArgs e)
- {
- if (e.Property.Name == "CountryId")
- {
- _colCountry.DisplayMemberPath = "Name";
- _colCountry.SelectedValuePath = "Id";
- _colCountry.SortMemberPath = "CountryId";
- _colCountry.FilterMemberPath = "CountryId";
- _colCountry.Header = "Country";
- _colCountry.Binding = new Binding() { Path = new PropertyPath("CountryId"), Mode = BindingMode.TwoWay };
- _colCountry.ItemsSource = Country.AllCountries;
- e.Column = _colCountry;
- }
- else if (e.Property.Name == "RegionId")
- {
- _colRegion.DisplayMemberPath = "Name";
- _colRegion.SelectedValuePath = "Id";
- _colRegion.SortMemberPath = "RegionId";
- _colRegion.FilterMemberPath = "RegionId";
- _colRegion.Header = "Region";
- _colRegion.Binding = new Binding() { Path = new PropertyPath("RegionId"), Mode = BindingMode.TwoWay };
- _colRegion.ItemsSource = Region.AllRegions;
- e.Column = _colRegion;
- }
- }
复制代码 |