如何清除组合框的先前值

时间:2014-10-31 16:51:40

标签: vb.net winforms

Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    lblbrand.Text = ComboBox1.SelectedValue.ToString()
    strb = lblbrand.Text


    connetionString = "Data Source=HRS\SQLEXPRESS;AttachDbFilename='E:\My project\forms\1\1\mobile shop management.mdf';Integrated Security=True"
    con = New SqlConnection(connetionString)
    con.Open()
    command = "select Model_id from mob where Brand ='" & lblbrand.Text & "'"
    cmd = New SqlCommand(command, con)
    Dim rd As SqlDataReader = cmd.ExecuteReader()
    If rd.HasRows = True Then
        While rd.Read()
            ComboBox2.Items.Add(rd("Model_id"))
        End While
    End If

End Sub

1 个答案:

答案 0 :(得分:0)

简单:

ComboBox2.Items.Clear()