GET FORM NAME WHICH FORM CONTROL ARE TRIGGERED IN C#?

ben reitman

Total Post:96

Points:676
Posted by  ben reitman
C# 
C#
 3512  View(s)
Ratings:
Rate this:

 Hi Expert!

I am creating a log file for stored generated exception, so I have needed to get which form control are fire. Please help me for getting name of current windows form are open.

Thanks in advance! 

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Get form name which form control are triggered in C#?

    Hi Ben!

    There are two way!

    If you want to used as globle then try this way

    string sFormName = this.FindForm().Name;

    Another way is, if you get form name at same page then used this way, but above code are used both places

    string SFormName = this.ActiveControl.FindForm().Name.ToString();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!