Pass Value of the ComboBox to Parameter

0

I am developing a solution in C # Windows forms and am having doubts on how to get one of the options in my combo box that is activated when a checked is clicked. This Combo has the option of yes and no, but when I pass it to the parameter the value comes in white.

if (chbSim.Checked)
{
    txtValor.Enabled = false;
    cmBSimNao.Enabled = true;
    param.Valor = cmBSimNao.Text;
    param.Nome = this.txtNome.Text;
    param.Descricao = this.txtDescricao.Text;
}
    
asked by anonymous 03.10.2017 / 15:30

1 answer

0

You should use the replace the following snippet:


    param.Valor = cmBSimNao.Text;

By


   param.Valor = cmBSimNao.SelectedItem.ToString();

The SelectedItem property gets or sets the selected item.

See reference: ComboBox.SelectedItem Property

    
03.10.2017 / 15:41