How to call a function in Form, from a Class?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    How to call a function in Form, from a Class?

    hai all, How to call a function in Form, from a Class? using c#.net.
    thanx in advance
    Nirmal.
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Have you tried sending th Form as a reference to the calss?

    the Form you refer to is infact a class too, which inherits windows forms class.
    So it is similar to calling a method from one object to another. however you should sebnd the Form class a reference so that you are referring to the same object, instead of creating more than one

    Comment

    • ammoos
      New Member
      • Apr 2007
      • 100

      #3
      if you want to call function from a class file to one form, then use

      class1 c1=new class1();
      c1.function1()

      if the class file not in the same application then refer the application that have the class file to the application that have the form

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by nirmalsingh
        hai all, How to call a function in Form, from a Class? using c#.net.
        thanx in advance
        Nirmal.
        1.) Depends on how the "function" has been declared. Is it static,private e.t.c
        2.) Remember a Form is also just another class.

        Comment

        Working...