CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #4
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167
    There are few ways to do this. Here is one.

    Lets say your main FORM class name is FMain and your child FORM class is called FChild. Then consider the following:
    Code:
    ' your main FORM
    public class FMain
    ...
      ' when you add a control the declaration should look like this
      friend withevents txtUsername as textbox
    ...
    
      ' show the child
      private sub showchild()
        dim myChild as new FChild()
        myChild.ParentForm = me
        ....
      end sub
    ...
    end class
    
    ' your child FORM
    public class FChild
    ...
      ' var to hold the parent
      public ParentForm as FMain = Nothing
    ...
      ' access the textbox in main form
      private sub DummyProc()
        if (not m_MainForm is nothing) then m_MainForm.txtUsername.Text = "From CHILD class."
      end sub
    ...
    end class
    Again, you have so many ways depending on how you instantiate the child form. The basic idea is to have a reference to the parent object so that you can access any exposed members (declared with either PUBLIC or FRIEND).

    //EDIT: variable name in child form was corrected.

    -Cool Bizs
    Last edited by coolbiz; May 9th, 2003 at 10:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured