C
C#16mo ago
aidun <33

❔ Progress bar value from 0 to 100 over 3 seconds for my splash screen

I CANNOT GET IT TO WORK
41 Replies
aidun <33
aidun <3316mo ago
Doombox
Doombox16mo ago
in what way isn't it working?
aidun <33
aidun <3316mo ago
it just isnt doing anything
Doombox
Doombox16mo ago
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
aidun <33
aidun <3316mo ago
yeah I believe
aidun <33
aidun <3316mo ago
Doombox
Doombox16mo ago
set steps to 1? having to guess a bit, Winforms sure is old
aidun <33
aidun <3316mo ago
nope steps to 1 and still nothing
Doombox
Doombox16mo ago
sure your timer is actually running? see no other obvious issues besides
aidun <33
aidun <3316mo ago
aidun <33
aidun <3316mo ago
should be
Angius
Angius16mo ago
Does the timer have the timer2_Tick method attached to the tick event?
Doombox
Doombox16mo ago
throw a breakpoint in there and see if it's actually being called and the value is actually changing
aidun <33
aidun <3316mo ago
uhh how
Angius
Angius16mo ago
$debug
MODiX
MODiX16mo ago
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.
Angius
Angius16mo ago
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
aidun <33
aidun <3316mo ago
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
Angius
Angius16mo ago
$code btw
MODiX
MODiX16mo ago
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/
aidun <33
aidun <3316mo ago
$codegif
Angius
Angius16mo ago
But is the timer2_Tick method actually attached to the tick event of the timer?
Doombox
Doombox16mo ago
doesn't seem to be anywhere in this code
aidun <33
aidun <3316mo ago
uh how would I do that like I said I suck at this
TheRanger
TheRanger16mo ago
can u attach it in designer mode?
Doombox
Doombox16mo ago
timer2.Tick += timer2_Tick; I would assume so, because that method signature seems auto generated
aidun <33
aidun <3316mo ago
where do I put this? under timer2 tick?
Doombox
Doombox16mo ago
tbh didn't even know you could create timers in the designer like that, Winforms is whack
Angius
Angius16mo ago
In the constructor most likely
aidun <33
aidun <3316mo ago
nothing stil
Doombox
Doombox16mo ago
can only imagine that the timer is set up weird in the designer, if that's actually a thing
TheRanger
TheRanger16mo ago
what is the elapsedtime of the tick event? show your splashscreen.designer.cs code
aidun <33
aidun <3316mo ago
designer for splashscreen
Doombox
Doombox16mo ago
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 seconds
TheRanger
TheRanger16mo ago
dont forget to remove this code from the constructor or this method will get called twice on every tick
aidun <33
aidun <3316mo ago
nothing nothing still
TheRanger
TheRanger16mo ago
did u try debugging? set a breakpoint and see if ur method is being called
Mayor McCheese
Mayor McCheese16mo ago
Probably something “reasonable” like max int.
Accord
Accord16mo ago
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.