c# - How can I stop multiple forms from opening? -


what happening here when click on student in mylistbox open details, windows form showing details show , windows form showing showing details first teacher in mylistbox.

if click on teacher in mylistbox windows form open them want. how can work people student? possible me like:

 if(mylistbox.selectedindex == student)  {     //code open details form here  } 

this how open details form people. if didnt use if statement says mylistbox.selectedindex == index. details form open.

private void openinfobutton_click(object sender, eventargs e) {             int index = 0;             foreach (student student in studentslist)             {                 if (mylistbox.selectedindex == index)                 {                     persondetails studentdetails = new persondetails(student);                     studentdetails.show();                     break;                 }                 index++;             }              foreach (teacher teacher in teacherlist)             {                 if (mylistbox.selectedindex == index)                 {                     persondetails teacherdetails = new persondetails(teacher);                     teacherdetails.show();                     break;                 }                 index++;             } } 

if @ sender object, it'll tell button clicked. there should know whether display student or teacher form


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -