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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:52:44+00:00 2026-06-05T02:52:44+00:00

I am creating a utility to insert few records into SQL after performing some

  • 0

I am creating a utility to insert few records into SQL after performing some calculations. I am using a background worker to stop the app from going into a non-responding state. As the process works I need to change few label values for which I use a delegate. Is it possible to pass my label as parameter to a function which has the delegate so I can re-use some of this code?

Below is the function I use to change to change value of label2. For label3 I have used another function that’s nearly identical. Is it possible to create a function that accepts label as parameter so that I can pass control name and the required message, and it does the updating for me?

Here is my code for changing label2:

public void changelabel(string msg)
{
    if (label2.InvokeRequired)
        label2.Invoke(new MethodInvoker(delegate
        {
            label2.Text = msg;
        }));
    else
        label2.Text = msg;
}
  • 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-05T02:52:45+00:00Added an answer on June 5, 2026 at 2:52 am

    Your labels are just fields of your form, as long as you don’t actually call methods or set properties on them, you can pass them around as you like:

    public void ChangeLabel(string msg, Label label) {
        if (label.InvokeRequired)
            label.Invoke(new MethodInvoker(delegate {
                label.Text = msg;
            }));
        else
            label.Text = msg;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating quite a few SSIS packages to drive document composition (e.g. utility bills,
Am trying to execute ssis package using dtexec utility from c# app(Creating New Process,
I'm creating a utility program which draws some (user customizable) icons onto other windows
I was creating a simple command line utility and using a dictionary as a
I need some test data for a MySQL utility that I am creating. Does
I'm creating a category over NSDate. It has some utility methods, that shouldn't be
As part of a testing utility I am creating some registry keys and applying
I am creating a utility which depends on libassuan aside other depends. While these
I'm creating a utility type application with a main and flipside view, and an
I'm creating a utility in C++ to be run on Linux which can convert

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.