一个用于访问,一个用于取货,当用户将访问或取货之一添加到列表中时,它也会添加到列表框中以向用户显示。
我的问题是,当我单击列表框中的项目时,例如 Indexchanged,我希望它打开与访问或交付相关的新 GUI,因此,如果他们单击访问,它会打开访问表单,如下所示代码,但我怎样才能让它区分列表,以便它知道要打开哪种形式?
private void lstVisits_SelectedIndexChanged(object sender, EventArgs e)
{
//Allow the user to click on the listbox to open a visit
//This event is called after the user has clicked on the list
int index = lstVisits.SelectedIndex;
//Get the index of the Visit that the user has clicked upon
Visits selected = theList.getVisits(index);
//Get the visits object from the list
Visitsform.visits = selected;
//Ensure that the appointment form references the selected visit
Visitsform.ShowDialog();
//Show the visits form
updateList();
//update the list as the user may have deleted the appointment