ComboBox has its old value after Clear()

前端 未结 8 958
心在旅途
心在旅途 2020-12-10 15:41

I have two comboBox cb_Brand and cb_Model on a winForm.

cb_Model populates values on brand Select. the problem is: if we sele

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 16:08

    I have a similar problem,tried cmb.resettext it clears text but not value.In my load form I have the below code: Dim cmd As New SqlCommand("SELECT stud_id,name FROM student_details WHERE stud_id NOT IN (SELECT stud_id FROM student_details WHERE hostel_id!=0)", sqlcont.Conn) Dim dr As SqlDataReader = cmd.ExecuteReader Dim dat As New DataTable Dim j As Integer For j = 0 To dat.Rows.Count - 1 dr.Read() Next dat.Load(dr) cmbstud.DisplayMember = "name" cmbstud.ValueMember = "stud_id" cmbstud.DataSource = New BindingSource(dat, Nothing) dr.Close() In my btnhostel click event I have the below code: frmallocateHostel_Load(Nothing, Nothing) this I put in attempt to reload my dataset and thus my comboboxes.Using cmbstud.resettext simply clears the text not the value.

提交回复
热议问题