i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How public static declaration for Statusbar Control ?
06-07-2015, 09:55 AM
Post: #1
How public static declaration for Statusbar Control ?
In C# assuming I have 2 forms: form1 and form2. I open Form1 drag Statusbar Control into Form1 with the following declaration:
Code:
public static void LogStatusBar(string status)
  {
       try
            {
                statusBar1.Text = "Thông báo: " + status; // error message here
            }
            catch (Exception ex)
            {

            }
  }
  private void form1_Load(object sender, EventArgs e)
   {
       ....
       LogStatusBar(Message);
       ....
   }

Form1 run before and open form2, form2 will be used together with function LogStatusBar Form1 (...) I have declared above, and in this form2. I declare the following code:
Code:
try
  {
     ....
  }
catch (Exception ex)
  {
      form1.LogStatusBar(ex.Message);
  }

My question posed here as Rebuild Solution in statusBar1.Text error will not be public static because of it, according to my understanding of this, verbatim error: Error 1 An object reference is required for the nonstatic field, method, or property 'Vidu.form1.statusBar1'. I want to declare the control statusBar1 was dragging this into the public static Form1 themselves to declare how the band through household property.


Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
Rainbow HOw to Bind Static Data In Grid View ?? gouravvishnoi 3 7,398 02-22-2011 04:53 AM
Last Post: nisar87
  Static Constructors in C# Shafiur Rahman 2 2,165 12-15-2010 08:17 AM
Last Post: Shafiur Rahman
  Singleton Pattern vs. Static Classes arti.porwal20@gmail.com 5 2,781 10-29-2010 04:17 AM
Last Post: arti.porwal20@gmail.com



User(s) browsing this thread: 1 Guest(s)