C
C#10mo ago
Kiragi

✅ would like help to fix my timer for windows forms

Hi, I’m in college and am working on my final project, I’m experiencing an issue with my timer (“no overload for ‘timer1_Tick’ matches delegate ‘EventHandler’”) in my windows form design, I am also looking to redo my project with instantiation to make it more efficient, help would be very much appreciated 👍🏼👌 (Only properly started using C# a few months ago)
No description
No description
No description
22 Replies
Pobiega
Pobiega10mo ago
That means its signature doesnt match the delegate type EventHandler lets check what signature the timer tick event has public delegate void EventHandler(object? sender, EventArgs e); Do you see the difference?
Kiragi
Kiragi10mo ago
Embarrassed to say I don’t really know lol?
Pobiega
Pobiega10mo ago
object? vs object try slapping a questionmark at the end of object in your timer1_Tick method only thing I can think of, because otherwise it looks valid to me also, your while loops are just for loops :p
Kiragi
Kiragi10mo ago
lol I know It’s an on going joke with my teacher But yeah it still isn’t happy with me ),:
Pobiega
Pobiega10mo ago
verify that you dont have two timer1_Tick methods
Kiragi
Kiragi10mo ago
I don’t think so Find command, only shows the one
Pobiega
Pobiega10mo ago
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void timer1_Tick(object sender, EventArgs e)
{

}
}

//designer.cs
timer1 = new System.Windows.Forms.Timer(components);
SuspendLayout();
//
// timer1
//
timer1.Tick += timer1_Tick;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void timer1_Tick(object sender, EventArgs e)
{

}
}

//designer.cs
timer1 = new System.Windows.Forms.Timer(components);
SuspendLayout();
//
// timer1
//
timer1.Tick += timer1_Tick;
works fine here are you sure its not a ghost problem?
Kiragi
Kiragi10mo ago
Maybe? How do you solve that?
Pobiega
Pobiega10mo ago
close down visual studio open a terminal in your project root dotnet build does it work?
Kiragi
Kiragi10mo ago
How do I open the terminal?
Pobiega
Pobiega10mo ago
For real?
Kiragi
Kiragi10mo ago
Pobiega
Pobiega10mo ago
there are thousand ways easiest is... open folder in file explorer shift right click in folder "open in terminal/command prompt/powershell"
Pobiega
Pobiega10mo ago
No description
Kiragi
Kiragi10mo ago
Ok got windows powershell
Pobiega
Pobiega10mo ago
dotnet build
Kiragi
Kiragi10mo ago
Yup
Pobiega
Pobiega10mo ago
works? errors?
Kiragi
Kiragi10mo ago
No errors Hopefully it works now
Pobiega
Pobiega10mo ago
okay, then its likely a ghost error, meaning VS cached the error and missed that you fixed it
Kiragi
Kiragi10mo ago
It works IT WORKSSS Thank you 👍🏼
Pobiega
Pobiega10mo ago
np
Want results from more Discord servers?
Add your server