Hello:
Is there a function that will give me the name of the current form that is active?
Reason is that I am in a class that is called and I need to know the current focused form name.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dipa AhujaRank #1,168 · 1.5K reputationPosted May 5, 2010, 11:00 PM EDT
Dipa AhujaRank #1,168 · 1.5K reputationPosted May 5, 2010, 7:54 AM EDT
GustavoRank #1,990 · 732 reputationPosted May 5, 2010, 7:58 AM EDT
I tried that but it gives me the MDIParent name not th child I am in. Can I change that so it will give me the child MDI?
GustavoRank #1,990 · 732 reputationPosted May 6, 2010, 6:52 AM EDT
Thanks, it worked.
This is my code, just in case someone else might need to see an example:
string TheFormText;
string TheFormName;
string TheFormTag;
Form TheForm = Form.ActiveForm;
TheFormText = TheForm.ActiveMdiChild.Text.ToString();
TheFormName = TheForm.ActiveMdiChild.Name.ToString();
try
{
TheFormTag = TheForm.ActiveMdiChild.Tag.ToString();
}
catch
{
TheFormTag = "
}
I had to do a try/catch on the Tag, because if it does not have one, it blows up.
Thanks again
BTW: It would be a lot easier if I was trying to find the Form name is I was actually in the Form. But in my case, I am in a ClassControl that called the ClassValidate. So I am 2 levels away. I hope this helps others.
Dipa AhujaRank #1,168 · 1.5K reputationPosted May 6, 2010, 7:52 AM EDT