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

The Archive Base Latest Questions

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

I have created a WindowsFormControlLibrary porject. It works fine, I can drop it on

  • 0

I have created a WindowsFormControlLibrary porject. It works fine, I can drop it on the forms,call its methods,etc …
but now as a property of it, I am passing the name of a Label to it. and I want this custom control to be able to use that label name and for example change its font to bold .
so the question is that if I have a WinForm and I have a Label on that form and my custom control on that form, then how can I tell my custom control to do something with that label which I am passing its name to it?

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

    First, if you wish to access a Control from your UserControl, you will need to use the FindForm() method.

    Second, you will be required to expose your TextBox control, for example, through a property of your form.

    Then, you would need to know the type of this Form returned by this FindForm() method.

    Once you know it, you need to type-cast this result to the correct type.

    So, here a sample untested pseudo-code to give you the idea:

    public partial class MyMainForm {
        private TextBox textBox1;
    
        public MyMainForm() {
            textBox1 = new Textbox();
            textBox1.Name = @"textBox1";
            textBox1.Location = new Point(10, 10);
            textBox1.Size = new Size(150, 23);
            this.Controls.Add(textBox1);
        }
    
        public Font MyTextBoxFont {
            get {
                return textBox1.Font;
            } set {
                if (value == null) return;
                textbox1.Font = value;
            }
        }
    }
    

    Then, assuming you have dropped your control on your form, your UserControl could have a property like so:

    public partial class MyUserControl {
        private Form GetContainerForm {
            get {
                return this.FindForm();
            }
        }
    
        // And later on, where you need to set your TextBox's font:
        private void SetContainerInputFieldFont(Font f) {
            if (GetContainerForm == null) return; // Or throw, depending on what you need to do.
    
            ((MyMainForm)GetContainerForm).MyTextBoxFont = f
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have created a UIButton programmatically, all works as expected but how can I use
Have created simple Ajax enabled contact forms before that have around 12 fields -
i have created and want to now import a dummy collection. one of the
I have created category for UIAlertView and overridden the delegate method willPresentAlertView but my
I have created custom validator that validates object comparing its fields (it uses EntityManager
I have created sample application that insert 12 rows in tableview.And inserted fine.When after
I have created a chrome extension which does something after its button is clicked.
I have created gwt maven project now I want to compile it and run
I have created an database file inside my asp.net application. Now from server explorer
I have created datatable from datatable.net plugin. datatable generated in right way, but further

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.