if else for forms displayed [modified]
-
I am creating a new window app and am having difficulty with resetting focus to a form instead of opening multiple instances of the form. I have a menu to open formA for example from the MainForm menu. I want to have the logic be something like (from click of menu from MainForm) If formA visiblity == true then { set focus to formA} else { formA.show} I can't seem to get the syntax for the if condition and the set focus command back to formA if it is already open. Any help would be appreciated, thanks! :confused: -- modified at 1:07 Saturday 27th May, 2006
-
I am creating a new window app and am having difficulty with resetting focus to a form instead of opening multiple instances of the form. I have a menu to open formA for example from the MainForm menu. I want to have the logic be something like (from click of menu from MainForm) If formA visiblity == true then { set focus to formA} else { formA.show} I can't seem to get the syntax for the if condition and the set focus command back to formA if it is already open. Any help would be appreciated, thanks! :confused: -- modified at 1:07 Saturday 27th May, 2006
if (formA.Visible == true)
{
formA.Select();
}
else
{
formA.Show();
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
I am creating a new window app and am having difficulty with resetting focus to a form instead of opening multiple instances of the form. I have a menu to open formA for example from the MainForm menu. I want to have the logic be something like (from click of menu from MainForm) If formA visiblity == true then { set focus to formA} else { formA.show} I can't seem to get the syntax for the if condition and the set focus command back to formA if it is already open. Any help would be appreciated, thanks! :confused: -- modified at 1:07 Saturday 27th May, 2006
IMC2006 wrote:
I can't seem to get the syntax for the if condition
It looks like you partially wrote it in VB The syntax for the
if
statement is:if (/*insert boolean condition here*/)
{
// Commands when condition is true
}
else
{
// Command when condition is false
}
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
if (formA.Visible == true)
{
formA.Select();
}
else
{
formA.Show();
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
I tried this but still it does not function correctly. If formA is not visible then it open a new instance no problem. the problem is if I go back and try and open it again, instead of selecting the previously opened form, it opens a new instance via formA.Show() even though copy of formA is open. If I change visible == true, then it believes an instance is already opened even though one is not opened. if (formA.Visible == false) { // shows new formA form formA.Show(); MessageBox.Show("New Form"); } else { // Reset focus to currently opened form formA.Select(); MessageBox.Show("Reset Focus to form"); }
-
I am creating a new window app and am having difficulty with resetting focus to a form instead of opening multiple instances of the form. I have a menu to open formA for example from the MainForm menu. I want to have the logic be something like (from click of menu from MainForm) If formA visiblity == true then { set focus to formA} else { formA.show} I can't seem to get the syntax for the if condition and the set focus command back to formA if it is already open. Any help would be appreciated, thanks! :confused: -- modified at 1:07 Saturday 27th May, 2006