❔ Progress bar value from 0 to 100 over 3 seconds for my splash screen
I CANNOT GET IT TO WORK
41 Replies
in what way isn't it working?
it just isnt doing anything
have you set min/max for the progress bar?
well maximum, I think the minimum is 0 by default, no idea what the maximum value is by default
yeah I believe
set steps to
1
? having to guess a bit, Winforms sure is oldnope
steps to 1 and still nothing
sure your timer is actually running? see no other obvious issues besides
should be
Does the timer have the
timer2_Tick
method attached to the tick event?throw a breakpoint in there and see if it's actually being called and the value is actually changing
uhh
how
$debug
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
Click next to the line number on any line inside of the tick method
Run in debug mode
If the program stops and shows debug info, the method gets called
If not, it doesn't
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Text;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Reflection.Emit;
namespace WindowsFormsApp2
{
public partial class SplashScreen : Form
{
Point lastPoint;
public SplashScreen()
{
InitializeComponent();
}
private void SplashScreen_Load(object sender, EventArgs e)
{
timer2.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Close();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (progressBar1.Value < 100)
{
progressBar1.Value += 1;
}
else
{
timer2.Stop();
}
}
}
}
thats the whole code
$code btw
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/$codegif
But is the
timer2_Tick
method actually attached to the tick event of the timer?doesn't seem to be anywhere in this code
uh how would I do that
like I said
I suck at this
can u attach it in designer mode?
timer2.Tick += timer2_Tick;
I would assume so, because that method signature seems auto generated
where do I put this?
under timer2 tick?
tbh didn't even know you could create timers in the designer like that, Winforms is whack
In the constructor most likely
nothing
stil
can only imagine that the timer is set up weird in the designer, if that's actually a thing
what is the elapsedtime of the tick event?
show your
splashscreen.designer.cs
codedesigner for splashscreen
don't see
timer2
's interval being set, default is 100ms I think
oh wait there it is
yeah it's moving 1 every 3 seconds
so it'd take 300 seconds to get to 100%
change the timer's interval to 30
, that should get you to 100% over 3 secondsdont forget to remove this code from the constructor or this method will get called twice on every tick
nothing
nothing
still
did u try debugging?
set a breakpoint and see if ur method is being called
Probably something “reasonable” like max int.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.