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