0

I have kind of a status field in form1 to be updated from different forms.

am coming back to winforms after few years, I need a reminder please, in c# . form1 has a var string lets say (is Text called status)

how would you update status field in form1 from different forms

thanks.

ramnz
  • 631
  • 1
  • 6
  • 24

1 Answers1

0

You can declare the Status field (suppose this is a Label) in Form1 like below:

public class Form1 : Form
{
    private Label _statusLabel;

    public static string Status
    {
        set
        {
            _statusLabel.Text = value;
        }
    }
}

Then you'll be able to set the status field from different forms like below:

Form1.Status = "PUT DESIRED STATUS HERE"

Edit: You can find StatusStrip (System.Windows.Forms.StatusStrip) in the toolbox under "Menus & Toolbars" tab. After adding it to your form, you'll see a dropdown icon from where you have to add ToolStripStatusLabel (System.Windows.Forms.ToolStripStatusLabel). Then just rename the "_statusLabel" with the newly added one.

If you need further assistance, feel free to ask !

Wasif Hossain
  • 3,900
  • 1
  • 18
  • 20