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 7033715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:05:55+00:00 2026-05-28T01:05:55+00:00

How do I get access to the parent controls of user control in C#

  • 0

How do I get access to the parent controls of user control in C# (winform). I am using the following code but it is not applicable on all types controls such as ListBox.

Control[] Co = this.TopLevelControl.Controls.Find("label7", true);
Co[0].Text = "HelloText"

Actually, I have to add items in Listbox placed on parent ‘Form’ from a user control.

  • 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-28T01:05:56+00:00Added an answer on May 28, 2026 at 1:05 am

    Description

    You can get the parent control using Control.Parent.

    Sample

    So if you have a Control placed on a form this.Parent would be your Form.

    Within your Control you can do

    Form parentForm = (this.Parent as Form);
    

    More Information

    • MSDN: Control.Parent Property

    Update after a comment by Farid-ur-Rahman (He was asking the question)

    My Control and a listbox (listBox1) both are place on a Form (Form1). I have to add item in a listBox1 when user press a button placed in my Control.

    You have two possible ways to get this done.

    1. Use `Control.Parent

    Sample

    MyUserControl

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.Parent == null || this.Parent.GetType() != typeof(MyForm))
                return;
    
            ListBox listBox = (this.Parent as MyForm).Controls["listBox1"] as ListBox;
            listBox.Items.Add("Test");
        }
    

    or

    2.

    • put a property public MyForm ParentForm { get; set; } to your UserControl
    • set the property in your Form
    • assuming your ListBox is named listBox1 otherwise change the name

    Sample

    MyForm

    public partial class MyForm : Form
    {
        public MyForm()
        {
            InitializeComponent();
            this.myUserControl1.ParentForm = this;
        }
    }
    

    MyUserControl

    public partial class MyUserControl : UserControl
    {
        public MyForm ParentForm { get; set; }
    
        public MyUserControl()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            if (ParentForm == null)
                return;
    
            ListBox listBox = (ParentForm.Controls["listBox1"] as ListBox);
            listBox.Items.Add("Test");
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access values from a user control MVVM in a parent
Trying to access a property from the parent page on my user control. Here's
I need to get access to the iTunes tags in an RSS feed using
I am looking to get access to all HTTP traffic on my machine (my
How do i get access to a control (linkbutton in my case) that is
i am trying to get access to whitepages using YQL. Unfortunately i don't have
Which permission needs my application to get access to the location of the user
Using EF how do i access values in a parent property when accessing a
Ive been trying to get the parent of this WebBrowser control. Somehow i can't
When I execute the following process-spawning code with a valid command string, I get

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.