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

  • Home
  • SEARCH
  • 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 6757183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:36:56+00:00 2026-05-26T13:36:56+00:00

How does one access WinForm controls such as ProgressBar properties from another class? Please

  • 0

How does one access WinForm controls such as ProgressBar properties from another class?

Please see my code below. I know this might not be the best option to expose WinForm class and its members as public but I am trying to clear the concept at this point.

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

        public void button1_Click(object sender, EventArgs e)
        {
            Class1 c = new Class1();
            c.loop();
        }

        public void PBSetup()
        {
            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
        }

        public void PBUpdate(int recno)

        {
            progressBar1.Value = Class1.recno;
        }
    }
}

namespace WindowsFormsApplication1
{
    class Class1
    {

        public static int recno;

        public void loop()
        {
            //How do I access Form1.PBSetup()??

            for (recno = 0; recno <= 100; recno++)
            {
                //How do I access Form1.PBUpdate(recno)??
            }
        }
    }
}
  • 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-26T13:36:57+00:00Added an answer on May 26, 2026 at 1:36 pm

    You do not want your business logic (your class) interacting with your UI (your form). The business logic should be agnostic of the presentation layer.

    If you want the form to respond to things that happen inside the class, you could consider exposing an Event inside the class that the form could subscribe to, much like it would subscribe to a button’s click event. The class instance could fire off the event completely unaware of who might be listening, and any subscribers would be notified.

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

Sidebar

Related Questions

This is a continuation of the post How does one access a method from
How does one go about referencing a class's static properties in xaml? In other
How does one convert an image from one color profile to another (screen to
How does one access a particular widget from within a custom layout while using
Where does one access the data from a parsed xml file when using libxml?
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
How does one add a comment to an MS Access Query, to provide a
How does one access command line flag (arguments) as environment variables in Erlang. (As
How does one construct and access a set of key-value pairs in C? To
In C on FreeBSD, how does one access the CPU utilization? I am writing

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.