Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 117,609 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 2,446 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Progress Bar

 
Reply to this topicStart new topic

Progress Bar

lolkwtf1516
post 8 Jul, 2008 - 07:28 AM
Post #1


New D.I.C Head

*
Joined: 5 Jul, 2008
Posts: 2

Hey, I'm trying to make a progress bar that the value increases every second, so I'm just about done and I get an error saying:

Error An object reference is required for the non-static field, method, or property 'WindowsFormsApplication1.Form1.loadingBar1' C:\Users\Connor\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs 35 17 WindowsFormsApplication1
========================================================================


csharp

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
backgroundWorker1.RunWorkerAsync();
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
System.Timers.Timer myTimer = new System.Timers.Timer();
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(DisplayTimeEvent);
myTimer.Interval = 1000;
myTimer.Start();

while (Console.Read() != 'q')
{
;
}
}
public static void DisplayTimeEvent(object source, System.Timers.ElapsedEventArgs e)
{
if (loadingBar1.Value >= 100)
{
}
else
{
loadingBar1.Value += 1;
}

}


}
}


Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif
User is offlineProfile CardPM

Go to the top of the page


zakary
post 8 Jul, 2008 - 08:07 AM
Post #2


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 382



Thanked 4 times

Dream Kudos: 175
My Contributions


remove static from public static void DisplayTimeEvent
User is offlineProfile CardPM

Go to the top of the page

public static void
post 12 Jul, 2008 - 10:40 AM
Post #3


New D.I.C Head

*
Joined: 19 May, 2008
Posts: 4


My Contributions


CODE
public void DisplayTimeEvent(object source, System.Timers.ElapsedEventArgs e)  
        {  
            if (loadingBar1.Value >= 100)  
            {  
            }  
            else  
            {  
               loadingBar1.Value += 1;  
            }
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 11:37PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month