R
RichGK
The first time I run my code the list box sends a selected index
changed event even though at this point there has been no activity
with the mouse. The value returned from SelectedValue according to the
debugger is System.Data.DataRowView.
How can I either stop this initial selected index changed event from
happening automatically or alternatively what can I check for so that
I can avoid executing further code if the selected value is not an
int? The problem with this is that I have to cast the returned object
before I can check it so cannot really check for a specific type.
Thanks,
Rich.
lbxTraining.DataSource = empTraining;
lbxTraining.DisplayMember = "display";
lbxTraining.ValueMember = "value";
private void lbxTraining_SelectedIndexChanged(object sender, EventArgs
e)
{
int i = int.Parse(lbxTraining.SelectedValue.ToString());
empTraining = dbEmployeeCom.getEmployeeTraining(i, employee);
}
changed event even though at this point there has been no activity
with the mouse. The value returned from SelectedValue according to the
debugger is System.Data.DataRowView.
How can I either stop this initial selected index changed event from
happening automatically or alternatively what can I check for so that
I can avoid executing further code if the selected value is not an
int? The problem with this is that I have to cast the returned object
before I can check it so cannot really check for a specific type.
Thanks,
Rich.
lbxTraining.DataSource = empTraining;
lbxTraining.DisplayMember = "display";
lbxTraining.ValueMember = "value";
private void lbxTraining_SelectedIndexChanged(object sender, EventArgs
e)
{
int i = int.Parse(lbxTraining.SelectedValue.ToString());
empTraining = dbEmployeeCom.getEmployeeTraining(i, employee);
}