Hi,
I am Designing a Vehicle Parts Database.
I have a first combobox 'cboVehiclemake ' that displays list of all Vehicles. The second combobox 'cboVehicleMode l' relies on the first cbo display all the related models.
when I clear all fields to add new data, second combo refuses to blank out. I am not sure why.
There are other controls and combos that behave as desired.
I have filtered and shown below, the code related to the two combos.
I am Designing a Vehicle Parts Database.
I have a first combobox 'cboVehiclemake ' that displays list of all Vehicles. The second combobox 'cboVehicleMode l' relies on the first cbo display all the related models.
when I clear all fields to add new data, second combo refuses to blank out. I am not sure why.
There are other controls and combos that behave as desired.
I have filtered and shown below, the code related to the two combos.
Code:
Private m_MakeID As Decimal
Code:
'Form_Load InitcboMake() InitcboModel()
Code:
Private Sub InitcboMake() 'First Combobox Dim dc As ACCDataContext = New ACCDataContext(g_strConnectionString) Dim MakesList = From ml In dc.tblVehicleMakes _ Order By ml.Descr Ascending _ Select ml If MakesList IsNot Nothing Then cboVehicleMake.DataSource = MakesList cboVehicleMake.DisplayMember = "Descr" cboVehicleMake.ValueMember = "ID" End If 'set to blank cboVehicleMake.SelectedIndex = -1 End Sub
Code:
Private Sub cboVehicleMake_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboVehicleMake.SelectedIndexChanged m_MakeID = cboVehicleMakeID.SelectedValue InitcboModel() End Sub
Code:
Private Sub InitcboModel() 'Second combobox Dim dc As ACCDataContext = New ACCDataContext(g_strConnectionString) Dim ModelsList = From ml In dc.tblVehicleModels _ Where ml.VehicleMakeID = m_MakeID _ Select ml If ModelsList IsNot Nothing Then cboVehicleModelID.DataSource = ModelsList cboVehicleModelID.DisplayMember = "Descr" cboVehicleModelID.ValueMember = "ID" End If 'set to blank cboVehicleModelID.SelectedIndex = -1 End sub
Code:
Private Sub ClearControls() cboVehicleMakeID.SelectedIndex = -1 m_MakeID = -1 InitcboModel() End Sub
Code:
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click ClearControls() End Sub
Comment