Good afternoon, the problem I have is this. There is a combobox in it data from dataset is loaded,

SqlDataAdapter sda = new SqlDataAdapter(type, con); DataSet ds = new DataSet(); con.Open(); sda.Fill(ds); con.Close(); cb_opf.DataSource = ds.Tables[0]; cb_opf.DisplayMember = "short"; cb_opf.ValueMember = "code"; 

On the form there is a field in which the user enters data and clicks the "Fill" button. The answer comes in json format in which there is a "code" field with values. Somehow you need to link the code field from the answer and the valueMember from the combobox so that the choice is made in the combobox.

  • It is not clear. The user fills out a form, then a request is sent somewhere and the response is returned in the form of json . So? And then what do you need to parse json and pull the value out of it by key key ? - Ev_Hyper
  • Yes, the answer comes in json format, I’ll pull out the data from it now I must forcibly select the value from the combobox. Ie: the value from the json code response: 1234 in the combobox is 1111, 1222, 1333, 1234. - Artneo
  • now how to select the value in the combobox? - Artneo
  • one
    cb_opf.SelectedValue = code; ? - Ev_Hyper

1 answer 1

Figured out

 combobox.SelectedValue = response.suggestionss[0].code; 

select the desired value in the combobox