So, I want the new values to load everytime the combobox selection is changed, but I don't want the accept button enabled until the textboxes are changed by the user. So, I fixed the problem by creating a boolean and setting it before and after filling the boxes.
But, is there a better way to do this?
VB Code:
Dim NonUI As Boolean = True Private Sub cmbTable_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTable.SelectedValueChanged Me.btnAccept.Enabled = False Me.NonUI = False Me.txtRollUp.Value = Me.cmbTable.Columns("RollupMarkup").CellValue(Me.cmbTable.SelectedIndex) Me.txtSell.Value = Me.cmbTable.Columns("SellMarkup").CellValue(Me.cmbTable.SelectedIndex) Me.NonUI = True End Sub Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click 'update the fields in the db Me.btnAccept.Enabled = False End Sub Private Sub txtRollUp_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRollUp.TextChanged If Me.NonUI = True Then Me.btnAccept.Enabled = True End Sub Private Sub txtSell_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSell.TextChanged If Me.NonUI = True Then Me.btnAccept.Enabled = True End Sub


Reply With Quote