reference a form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike J

    #1

    reference a form

    Hi i have a class running
    how do i reference from within the class
    the form

    class myclass
    {
    }
    public myclass(object ofrm)
    i can't see the form at develop time to see its type
    if i use object will not compile
    object oform=ofrm;
    im still lil new at c#
    tia
    MJ


  • Michael C

    #2
    [Multipost]

    Please don't multipost. This has been answered elsewhere.


    Comment

    • Phill W.

      #3
      Re: reference a form

      Mike J wrote:
      Hi i have a class running
      how do i reference from within the class
      the form
      >
      class myclass
      {
      }
      public myclass(object ofrm)
      i can't see the form at develop time to see its type
      if i use object will not compile
      Depends on what you want to /do/ with the Form within your method.

      If using it as a Forms.Form is good enough - say, to move it around on
      the screen - then ...

      public myclass(System. Windows.Forms.F orm ofrm)

      .... would do.

      If you want to do something more /specific/ - like calling a "known"
      method on that form - then you're [almost certainly] going to have to
      /get/ the Type of the Form at design time. Without this, you're reduced
      to Late Bound execution that usually results in more trouble (i.e.
      run-time errors) than it's worth.

      /Why/ don't you know the Type of the Form at design time?
      Is this some sort of "plug-in" model (in which case, an Interface might
      be the way to go).

      HTH,
      Phill W.

      Comment

      • Mike J

        #4
        Re: reference a form

        i do know the form type.....
        what i have is a Service running and executing a class to process sql
        data........
        also i have a front end app..for testing this service class
        so i want to update come text boxes of the process while its running.....eg
        Test mode
        Tks
        MJ



        "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
        news:f0a7qo$8aj $1@south.jnrs.j a.net...
        Mike J wrote:
        >
        >Hi i have a class running
        >how do i reference from within the class
        >the form
        >>
        >class myclass
        >{
        >}
        >public myclass(object ofrm)
        >i can't see the form at develop time to see its type
        >if i use object will not compile
        >
        Depends on what you want to /do/ with the Form within your method.
        >
        If using it as a Forms.Form is good enough - say, to move it around on the
        screen - then ...
        >
        public myclass(System. Windows.Forms.F orm ofrm)
        >
        ... would do.
        >
        If you want to do something more /specific/ - like calling a "known"
        method on that form - then you're [almost certainly] going to have to
        /get/ the Type of the Form at design time. Without this, you're reduced
        to Late Bound execution that usually results in more trouble (i.e.
        run-time errors) than it's worth.
        >
        /Why/ don't you know the Type of the Form at design time?
        Is this some sort of "plug-in" model (in which case, an Interface might be
        the way to go).
        >
        HTH,
        Phill W.

        Comment

        Working...