populate combobox using collectioniewSource

zleug 51 Reputation points
2020-03-24T19:31:55.567+00:00

Hi All.
I'm trying to populate combobox. That is my code:

MyDataSet MyDataSet = new MyDataSet();

MyDataSetTableAdapters.DepartmentTableAdapter DepartmentTableAdapter = new MyDataSetTableAdapters.DepartmentTableAdapter();

BindingListCollectionView cvDepartment;

DepartmentTableAdapter.Fill(MyDataSet.Department, 0);

cvDepartment = CollectionViewSource.GetDefaultView(MyDataSet.Department);

DepartmentComboBox.ItemsSource = cvDepartment;

What is wrong in populate combobox?

Thanks.

Community Center | Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
    2023-07-16T06:33:50.5466667+00:00

    Ensure that the CollectionViewSource.GetDefaultView method is correctly retrieving the default view for the MyDataSet.Department table and assigning it to cvDepartment. Verify that the cvDepartment variable is not null after this operation.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.