Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 407677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:37:05+00:00 2026-05-12T17:37:05+00:00

I have a child form which has a find form in it. I set

  • 0

I have a child form which has a find form in it. I set the find form’s owner to the child form like so:

private void ShowFindForm()
{
  FindForm.Show(this);
}

which then allows me to access it’s properties like this:

private void FindNext()
{
  TreeNode matchingNode = ...
  ... etc
  ... etc

  OwnerForm form = this.Owner as OwnerForm;
  form.TreeView.SelectedNode = matchingNode;
}

This works perfectly fine until I shove the owner form into an MDI form, whereby the MDI form promptly takes ownership of the find form and messes it all up. How do I get around this?

UPDATE:

I can hack around this by iterating through the MDI form’s MdiChildren property until I find the form I want, but this seems a bit cowboy-ish.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:37:05+00:00Added an answer on May 12, 2026 at 5:37 pm

    A simple solution to this problem is to create a public OwnerForm property on your child form like this:

    public OwnerForm myOwner;
    

    and then edit your ShowFindForm() method to this:

    private void ShowFindForm()
    {
        FindForm.myOwner = this;
        FindForm.Show(this);
    }
    

    and then change the second-to-last line in your child form’s FindNext() method to this:

    OwnerForm form = this.myOwner;
    

    myOwner should probably actually be a private property with public get and set methods, but this is just to illustrate the principle. Basically, instead of assuming that your child form’s Owner is the form whose properties you want to access (an assumption that breaks in the MDI world, as you’ve found), you’re explicitly creating a reference to the form you want.

    As a side note, many would consider your code sample to be a violation of the OOP principle of encapsulation, since you’re manipulating one form’s controls from another form. I’ve seen worse crimes against humanity, myself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a main form which upon loading, opens a child form for
Please guide and help me. I have a MDI parent form which has a
I have a child form that is throwing an ApplicationException in the Load event
I have a need to close a parent form from within child form from
I have object1 as a child of a Canvas. object1 has a MouseLeftButtonDown event
I have a form that calls a custom child form. The child form is
I have Parent page and a Child page('empW.cfm'),which is nothing but a popup window
I have a login.jsp page which contains a login form. Once logged in the
This one's really kicking my backside. I have a form, spawned and owned by
I have a process which opens a form and a tray icon on startup.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.