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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:02:21+00:00 2026-05-11T03:02:21+00:00

I’m trying to create my own error window for the project I am working

  • 0

I’m trying to create my own error window for the project I am working on. When I show my error window I have no way to pass the error message, and user message to the Error window because the ‘ErrorMessage.Text’ cannot be seen in the classes I make.

I went into the form designer generated code and tried to make the TextBox static, but that just breaks things. Can I make a TextBox public / static so I can change it from another form?

  1. How do I make a TextBox Static Public so I can manipulate it across other forms, or is there another method for doing this?

EDIT:

Okay, for more information…

I have my own Form created. It is called ‘formErrorWindow.’ I need to display the form that i’ve pre-designed with the message set from another form. The only way I can do this is if I create a Function in the windows designer area for the form, and I set the variables with ‘this.errorMsg.text = error.’ The only way I can see that function is if I set it to static. If I set the function to Static, when I try and put ‘this.errorMsg.Text = error’ I get this error: An object reference is required for the non-static field, method, or property.

Here is what I’ve attempted:

    namespace LCR_ShepherdStaffupdater_1._0     {         partial class formErrorWindow         {             /// <summary>             /// Required designer variable.             /// </summary>             public System.ComponentModel.IContainer components = null;              /// <summary>             /// Clean up any resources being used.             /// </summary>             /// <param name='disposing'>true if managed resources should be disposed; otherwise, false.</param>             ///               protected override void Dispose(bool disposing)             {                 if (disposing && (components != null))                 {                     components.Dispose();                 }                 base.Dispose(disposing);             }              #region Windows Form Designer generated code              /// <summary>             /// Required method for Designer support - do not modify             /// the contents of this method with the code editor.             /// </summary> // ********* HERE IS THE FUNCTION THAT IVE ADDED BELOW. THIS WOULD WORK BUT.... *********      public static void showError(string errorTitle, string usrMsg, string errorMsg)     {         formErrorWindow errorWindow = new formErrorWindow();         errorMsgItem.Text = errorMsg;         errorTitleItem.Text = 'Error! : ' + errorTitle;         usrMsgItem.Text = usrMsg;         errorWindow.ShowDialog();     } // ********* HERE IS THE FUNCTION THAT IVE ADDED ABOVE. THIS WOULD WORK BUT.... ********* // ********* I get an error: 'An object reference is required for the non-static field, method, or property.' *********             public void InitializeComponent()             {                 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(formErrorWindow));                 this.usrMsgItem = new System.Windows.Forms.TextBox();                 this.errorTitleItem = new System.Windows.Forms.Label();                 this.errorMsgItem = new System.Windows.Forms.TextBox();                 this.button1 = new System.Windows.Forms.Button();                 this.panel1 = new System.Windows.Forms.Panel();                 this.label2 = new System.Windows.Forms.Label();                 this.panel1.SuspendLayout();                 this.SuspendLayout();                 //                  // usrMsgItem                 //                  this.usrMsgItem.Enabled = false;                 this.usrMsgItem.Location = new System.Drawing.Point(13, 37);                 this.usrMsgItem.Multiline = true;                 this.usrMsgItem.Name = 'usrMsgItem';                 this.usrMsgItem.Size = new System.Drawing.Size(334, 81);                 this.usrMsgItem.TabIndex = 0;                 this.usrMsgItem.Text = 'Undefined';                 //                  // errorTitleItem                 //                  this.errorTitleItem.AutoSize = true;                 this.errorTitleItem.Font = new System.Drawing.Font('Microsoft Sans Serif', 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));                 this.errorTitleItem.ForeColor = System.Drawing.Color.Red;                 this.errorTitleItem.Location = new System.Drawing.Point(12, 9);                 this.errorTitleItem.Name = 'errorTitleItem';                 this.errorTitleItem.Size = new System.Drawing.Size(152, 20);                 this.errorTitleItem.TabIndex = 1;                 this.errorTitleItem.Text = 'Error! : Undefined';                 //                  // errorMsgItem                 //                  this.errorMsgItem.Enabled = false;                 this.errorMsgItem.Location = new System.Drawing.Point(0, 21);                 this.errorMsgItem.Multiline = true;                 this.errorMsgItem.Name = 'errorMsgItem';                 this.errorMsgItem.Size = new System.Drawing.Size(329, 101);                 this.errorMsgItem.TabIndex = 2;                 this.errorMsgItem.Text = 'Undefined';                 //                  // button1                 //                  this.button1.Location = new System.Drawing.Point(272, 256);                 this.button1.Name = 'button1';                 this.button1.Size = new System.Drawing.Size(75, 23);                 this.button1.TabIndex = 3;                 this.button1.Text = 'Continue';                 this.button1.UseVisualStyleBackColor = true;                 this.button1.Click += new System.EventHandler(this.button1_Click);                 //                  // panel1                 //                  this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));                 this.panel1.Controls.Add(this.label2);                 this.panel1.Controls.Add(this.errorMsgItem);                 this.panel1.Location = new System.Drawing.Point(12, 124);                 this.panel1.Name = 'panel1';                 this.panel1.Size = new System.Drawing.Size(335, 126);                 this.panel1.TabIndex = 4;                 //                  // label2                 //                  this.label2.AutoSize = true;                 this.label2.Font = new System.Drawing.Font('Microsoft Sans Serif', 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));                 this.label2.Location = new System.Drawing.Point(68, 1);                 this.label2.Name = 'label2';                 this.label2.Size = new System.Drawing.Size(189, 17);                 this.label2.TabIndex = 3;                 this.label2.Text = 'Technical Error Message';                 //                  // formErrorWindow                 //                  this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);                 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;                 this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));                 this.ClientSize = new System.Drawing.Size(359, 290);                 this.Controls.Add(this.panel1);                 this.Controls.Add(this.button1);                 this.Controls.Add(this.errorTitleItem);                 this.Controls.Add(this.usrMsgItem);                 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;                 this.Icon = ((System.Drawing.Icon)(resources.GetObject('$this.Icon')));                 this.MaximizeBox = false;                 this.MinimizeBox = false;                 this.Name = 'formErrorWindow';                 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;                 this.Text = 'Error!';                 this.VisibleChanged += new System.EventHandler(this.formErrorWindow_VisibleChanged);                 this.panel1.ResumeLayout(false);                 this.panel1.PerformLayout();                 this.ResumeLayout(false);                 this.PerformLayout();              }              #endregion              private System.Windows.Forms.Button button1;             private System.Windows.Forms.Panel panel1;             private System.Windows.Forms.Label label2;             public System.Windows.Forms.TextBox usrMsgItem;             public System.Windows.Forms.Label errorTitleItem;             public System.Windows.Forms.TextBox errorMsgItem;         }     } 

Look for the function I’ve added above. How do I get that to compile and do what I want it to do WITHOUT that error I keep getting: An object reference is required for the non-static field, method, or property.

  • 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. 2026-05-11T03:02:22+00:00Added an answer on May 11, 2026 at 3:02 am

    Yes! have a function made public that can receive this text:

    pseudo: public void updateTextBox(string new_text) 

    and have the function update the textbox from there.

    don’t mix UI with logic.

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

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the following simple expression. ^([0-9]-?){7,8}[0-9]$ The drawback… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer Put this in your ~/.inputrc: C-L: backward-kill-line (assuming by "clear"… May 12, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer Here is how you could do it using the Dojo… May 12, 2026 at 12:15 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.