Home Forums WinForms controls Other WinForms controls Clear combobox text Reply To: Clear combobox text

User (Old forums)
Post count: 23064


Heres whats happening. I have two combo boxes one named job and one named unit. The job combo is populated with jobnumbers. When a job number is selected it populates the unit combo with relevant unit numbers. The user then selects a unit and the program continues. When a user now selects a different job the unit combo is cleared and repopulated with new unit numbers. The problem I have is that the unit that was selected in the first go around is still showing and I need the unit combo display to be blank at this stage. Heres the code:

Private Sub cboJobNum_SelectedItemChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboJobNum.SelectedItemChanged
Dim strSql As String
Dim cmd As MySqlCommand
Dim drData As MySqlDataReader
Dim strUnitNum As String
Dim ComboItem As Xceed.SmartUI.Controls.ToolBar.ComboBoxItem

‘clear any old items

‘first populate the stock type combo
strSql = “SELECT UnitNum FROM Shared.tblProject WHERE ProjectNum ='” & cboJobNum.SelectedItem.Text & _
“‘ ORDER BY UnitNum”
‘start a reader
cmd = New MySqlCommand(strSql, cnn)
drData = cmd.ExecuteReader
‘Add the list of crates to the Crate Combo Box
Do While drData.Read()
strUnitNum = drData(“UnitNum”)
ComboItem = New Xceed.SmartUI.Controls.ToolBar.ComboBoxItem(strUnitNum)

‘close the reader
If Not drData Is Nothing Then
End If
End Sub

thanks Nick Steele

Imported from legacy forums. Posted by Nick (had 560 views)