M
M
Mikhailushka2018-11-30 01:08:45
WPF
Mikhailushka, 2018-11-30 01:08:45

How to display text in a collapsed combobox?

There is a datagrid in which there is a combobox, now you need to double-click on the cell in the grid in which the combobox is located and then select its value.
How to make it so that when the window is initialized, the combobox would already be active and some of the values ​​\u200b\u200bwere already set in it?
Here is combobox

<DataGridComboBoxColumn x:Name="testComboBox" ItemsSource="{Binding category}" Header="Категории" DisplayMemberPath="id_category" SelectedValuePath="name_category"/>

Here's how it fills up now
private void FilltestComboBox()
        {
            addDataAdapter = new MySqlDataAdapter
            {
                SelectCommand = new MySqlCommand()
                {
                    Connection = programQuery,
                    CommandText = "SELECT * FROM category"
                }
            };

            addDataAdapter.Fill(addDataSet, "category");
            DataTable dtEmpName = addDataSet.Tables["category"];
            testComboBox.ItemsSource = ((IListSource)dtEmpName).GetList();
            testComboBox.SelectedValuePath = "id_category";
            testComboBox.DisplayMemberPath = "name_category";

        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question