jfackler
Junior Contributor
Anyone know how I can keep an event from firing on the page load only?
The combobox cmbPTOweekone in the third box of code is bound to a dataset:
The binding context is passed in as a public variable from a dialog box requesting the selection of an employyee.
Everything works fine except when I change the binding context and the form is reinstantiated, the cmbPTOweekone_SelectedIndexChanged event is fired and the msgbox is fired if the condition is met. The value it's comparing however, is that from the previous binding context.
It seems to be a timing issue. The comboboxes bind correctly and the msgbox only fires when the condition is met.
Thanks,
Jon
The combobox cmbPTOweekone in the third box of code is bound to a dataset:
Visual Basic:
lblPTOAnnual.DataBindings.Add("text", dataset1, "Employees.BeginningPTO")
lblPTORemain.DataBindings.Add("Text", dataset1, "Employees.RemainingPTO")
cmbPTOweekone.DataBindings.Add("SelectedItem", dataset1, "Employees.WeekOnePTO")
cmbPTOweektwo.DataBindings.Add("SelectedItem", dataset1, "Employees.WeekTwoPTO")
cmbHolidayHoursOne.DataBindings.Add("SelectedItem", dataset1, "Employees.WeekOneHoliday")
Visual Basic:
Me.BindingContext(dataset1, "Employees").Position = intSelectedEmployee
Visual Basic:
Private Sub cmbPTOweekone_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPTOweekone.SelectedIndexChanged
If cmbPTOweektwo.Text = "" Then
cmbPTOweektwo.SelectedIndex = 0
End If
If CInt(cmbPTOweekone.Text) > (CInt(dataset1.Tables("Employees").Rows(intSelectedEmployee).Item("RemainingPTO")) - CInt(cmbPTOweektwo.Text)) Then
cmbPTOweekone.SelectedIndex = 0
MessageBox.Show("You have taken more PTO than remains in your banked Paid Time Off. Please correct your entry.", "PTO Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
fillthetotals()
End Sub
Thanks,
Jon