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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:59:13+00:00 2026-06-05T13:59:13+00:00

In Form1 i have label2 in the designer and i added a code: public

  • 0

In Form1 i have label2 in the designer and i added a code:

public void lbl2(string text)
        {
            label2.Text = text;
        }

In the new class top i added:

private static AnimationEditor.Form1 fr1 = new AnimationEditor.Form1();

And in the new class event im updating the label2.Text like this:

int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr pBuffer, int bufferLen)
        {
            using (var bitmap = new Bitmap(_width, _height, _width * 3, PixelFormat.Format24bppRgb, pBuffer))
            {
                bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);
                if (SaveToDisc)
                {
                    String tempFile = _outFolder + _frameId + ".bmp";
                    if (File.Exists(tempFile))
                    {
                        fr1.lbl2(_frameId.ToString();
                    }
                    else
                    {
                        bitmap.Save(Path.Combine(_outFolder, _frameId + ".bmp"));
                    }
                    _frameId++;
                }
                else
                {
                    if (Images == null)
                        Images = new List<Bitmap>();
                    Images.Add((Bitmap)bitmap.Clone());
                }
            }
            return 0;
        }

Thel ine that is doing the updating is:

fr1.lbl2(_frameId.ToString();

Now i used breakpoint on this line in the new class and also in Form1 on the label2.Text in the public function and i saw that the label2 text is changing first its 0 then 1 then 2 and so on.

But in fact in realtime when im running the application the label2 dosent change its all the time the text saty as label2

This is the Form1 button click event when i click on it its doing the new class code:

private void button5_Click(object sender, EventArgs e)
        {
            wmv = new Polkan.DataSource.WmvAdapter(@"d:\VIDEO0040.3gp", sf);
            wmv.SaveToDisc = true;
            wmv.Start();
            wmv.WaitUntilDone();
        }
  • 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-05T13:59:14+00:00Added an answer on June 5, 2026 at 1:59 pm

    I think the quick answer is to pass in the reference of the label to the class:

    private Label lbl;
    
    public WmvAdapter(string file, string outFolder, Label label) {
      // yada-yada-yada
      lbl = label;
    }
    

    Your routine would change to:

    if (File.Exists(tempFile))
    {
      lbl.Text = _frameId.ToString();
    }
    

    Your click event:

    private void button5_Click(object sender, EventArgs e)
    {
      wmv = new Polkan.DataSource.WmvAdapter(@"d:\VIDEO0040.3gp", sf, this.Label2);
      wmv.SaveToDisc = true;
      wmv.Start();
      wmv.WaitUntilDone();
    }
    

    The longer answer is to have your class raise an event and have your form listen for it.

    Having your class be aware of the form is not the best coding practice.

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

Sidebar

Related Questions

If I have this code: Label label1 = new Label(); Form1.Controls.Add(label1); Label label2 =
I have some variables in the class public ref class Form1 that I need
I have a control that is created like so: public partial class MYControl :
I havea a UserControl1 (in witch I have an Label1 ) in Form1 .
I have a form element defined as: <div class=field> <div class=name> <label for=User_LastName> Last
I have this code in my view: echo form_label('State', 'state'); $options = array( 'No
I was using multithreading in my window form. Following is my class. I have
I have a new project. I drop a textbox control on it. I open
Somehow forms and controls created through Visual Studio and the designer have the great
I have a label called LabelX1. This is on form2. On form1, i have

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.