C# DropDownList cant get value from CellClick DataGrid

Viewed 19

I have a datagrid in C#. In my windows a single Combobox with DropDownList. But when i try to get the value in the datagrid with CellClick the value dont change. With DropDown works fine, but for my project i need DropDownList. I create a label to check if this label change. The label change but not the combobox. What is wrong ?

private void CaballerosDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        Cursor.Current = Cursors.WaitCursor;
        int index = e.RowIndex;
        DataGridViewRow selectedRow = CaballerosDataGridView.Rows[index];
        CaballerosDataGridView.Columns[0].Visible = true;
        NombreCaballerosTextBox.Text = selectedRow.Cells[1].Value.ToString();

        string cat = selectedRow.Cells[2].Value.ToString();
        CategoriaCaballerosComboBox.Text = cat;
        ////string item = selectedRow.Cells[2].Value.ToString();
        ////CategoriaCaballerosComboBox.SelectedValue = item;
        ////CategoriaCaballerosComboBox.Text = item;
        ////string item = selectedRow.Cells[2].Value.ToString();
        ////CategoriaCaballerosComboBox.SelectedValue = CaballerosDataGridView.CurrentCell.Value
        CaballerosDataGridView.Columns[3].Visible = true;
        string mypic = selectedRow.Cells[3].Value.ToString();
        CaballeroPictureBox.Image = Image.FromFile(mypic);

        label3.Text = selectedRow.Cells[2].Value.ToString();
        
        Cursor.Current = Cursors.Default;




    }

Thanks for help....

1 Answers

Ok i find

CategoriaCaballerosComboBox.Text = selectedRow.Cells[2].Value.ToString().Trim();

Related