active form name problems..
-
ok my problem is.. when i enter this code inside the load event it returns the name of the form opened before this form.. private void editForm_Load(object sender, System.EventArgs e) { MessageBox.Show(ActiveForm.Name.ToString()); } which returns AdminPanel ( which is the previous form ) but what i want is to see editForm ( which is the form i'm currently opening ) i know its because the form is loading and thats why the currently activeform is AdminPanel but i need to see editForm because: i have a listbox which gets data from mssql and puts the data to listbox, and someforms of i use are inherited from editForm so while this editForm is loading i want to fetch the data from the unique table so i can see the datas in the listbox after the form is loaded so my code should be something like this.. private void editForm_Load(object sender, System.EventArgs e) { Classes.editClass eC = new HalkDanisv03.Classes.editClass(); // create new object if(ActiveForm.Name.ToString() == "editEmployee") { eC.getStaffUsername(xList,"employeeinfo"); // employeeinfo is the name of the tablename } else if(ActiveForm.Name.ToString() == "editManager") { eC.getStaffUsername(xList,"managerinfo"); //managerinfo is the name of the tablename } } any help would be great.. thx guys.. good coding
-
ok my problem is.. when i enter this code inside the load event it returns the name of the form opened before this form.. private void editForm_Load(object sender, System.EventArgs e) { MessageBox.Show(ActiveForm.Name.ToString()); } which returns AdminPanel ( which is the previous form ) but what i want is to see editForm ( which is the form i'm currently opening ) i know its because the form is loading and thats why the currently activeform is AdminPanel but i need to see editForm because: i have a listbox which gets data from mssql and puts the data to listbox, and someforms of i use are inherited from editForm so while this editForm is loading i want to fetch the data from the unique table so i can see the datas in the listbox after the form is loaded so my code should be something like this.. private void editForm_Load(object sender, System.EventArgs e) { Classes.editClass eC = new HalkDanisv03.Classes.editClass(); // create new object if(ActiveForm.Name.ToString() == "editEmployee") { eC.getStaffUsername(xList,"employeeinfo"); // employeeinfo is the name of the tablename } else if(ActiveForm.Name.ToString() == "editManager") { eC.getStaffUsername(xList,"managerinfo"); //managerinfo is the name of the tablename } } any help would be great.. thx guys.. good coding
Would
this.Name
not work?The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-
Would
this.Name
not work?The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
it works :) thx so much :)
-
ok my problem is.. when i enter this code inside the load event it returns the name of the form opened before this form.. private void editForm_Load(object sender, System.EventArgs e) { MessageBox.Show(ActiveForm.Name.ToString()); } which returns AdminPanel ( which is the previous form ) but what i want is to see editForm ( which is the form i'm currently opening ) i know its because the form is loading and thats why the currently activeform is AdminPanel but i need to see editForm because: i have a listbox which gets data from mssql and puts the data to listbox, and someforms of i use are inherited from editForm so while this editForm is loading i want to fetch the data from the unique table so i can see the datas in the listbox after the form is loaded so my code should be something like this.. private void editForm_Load(object sender, System.EventArgs e) { Classes.editClass eC = new HalkDanisv03.Classes.editClass(); // create new object if(ActiveForm.Name.ToString() == "editEmployee") { eC.getStaffUsername(xList,"employeeinfo"); // employeeinfo is the name of the tablename } else if(ActiveForm.Name.ToString() == "editManager") { eC.getStaffUsername(xList,"managerinfo"); //managerinfo is the name of the tablename } } any help would be great.. thx guys.. good coding
FYI, your form isn't "active" until AFTER the Load event completes. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome