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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:59:50+00:00 2026-06-14T04:59:50+00:00

If a Superclass has a function A() which changes a Label to Hello World.

  • 0

If a Superclass has a function A() which changes a Label to “Hello World”. How can I get a subclass to call A() with the same result? As of now, I get no compile error, but the text won’t change!

Example code:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();            
    }

    private void button1_Click(object sender, EventArgs e)
    {
        FunctionA("Hello");
    }  

    public void FunctionA(string s)
    {
        label1.Text = s;
    }

    private void button2_Click(object sender, EventArgs e)
    {
        Test t = new Test();
    }
}

class Test : Form1
{
    public Test()
    {
        FunctionA("World");
    }
}
  • 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-06-14T04:59:53+00:00Added an answer on June 14, 2026 at 4:59 am

    Both the Forms must be having their own Label control to display messages. You might be using one Label to show the message which is not part of displaying Form.

    I am not sure what are to trying to achieve but why don’t you just pass the Label control to FunctionA to modify the message this way:

    public void FunctionA(ref Label lbl, string s)
    {
        lbl.Text = s;
    }
    

    ADDED: You can do it this way:

    1. First creating the instance of FormA.

      static void Main()
      {
          //...
          FormA frmA = new FormA();
          Application.Run(frmA);
      }
      
    2. Passing the instance of FormA to FormB by exposing a parameterized constructor for any manipulation in FormA from within FormB.

      FormB frmB = new FormB(frmA);
      
      //...
      
      public partial class FormB : Form
      {
          public FormB()
          {
              InitializeComponent();
          }
      
          //parameterized constructor
          public FormB(FormA obj)
          {
              FormA = obj;
              InitializeComponent();
          }
      
          public FormA FormA { get; set; }   
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a superclass we can call class A and few subclasses, e.g. class
I have a class which I cant change (SuperClass) that has an interface for
In JavaScript, every function's prototype object has a non-enumerable property constructor which points to
I have a generic subclass of Backbone.View which has a close event listener. var
The Objective C runtime reference has the function class_getSuperclass for getting the superclass of
What happens when a superclass has a field marked final, but a subclass overrides
I understand the Meta class can be inherited if the superclass has abstract=True, but
I have a class extends NamedParameterJdbcDaoSupport. well this superclass has a final setDataSource method
Say I have superclass which listens to a notification: @implementation SuperClass - (void)viewWillAppear:(BOOL)animated {
I've got an Abstract PHP superclass, which contains code that needs to know which

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.