TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dong Lam Trien
830
986
147.3k
How public static declaration for Statusbar Control ?
Jun 7 2015 5:45 AM
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);
....
}
[/code]
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);
}
[/code]
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.
Reply
Answers (
1
)
create backup in c# through win form (please read details)
How to Increase item width in listview c#