C
C#11mo 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
Pobiega11mo 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
KiragiOP11mo ago
Embarrassed to say I don’t really know lol?
Pobiega
Pobiega11mo 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
KiragiOP11mo ago
lol I know It’s an on going joke with my teacher But yeah it still isn’t happy with me ),:
Pobiega
Pobiega11mo ago
verify that you dont have two timer1_Tick methods
Kiragi
KiragiOP11mo ago
I don’t think so Find command, only shows the one
Pobiega
Pobiega11mo 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
KiragiOP11mo ago
Maybe? How do you solve that?
Pobiega
Pobiega11mo ago
close down visual studio open a terminal in your project root dotnet build does it work?
Kiragi
KiragiOP11mo ago
How do I open the terminal?
Pobiega
Pobiega11mo ago
For real?
Kiragi
KiragiOP11mo ago
Pobiega
Pobiega11mo ago
there are thousand ways easiest is... open folder in file explorer shift right click in folder "open in terminal/command prompt/powershell"
Pobiega
Pobiega11mo ago
No description
Kiragi
KiragiOP11mo ago
Ok got windows powershell
Pobiega
Pobiega11mo ago
dotnet build
Kiragi
KiragiOP11mo ago
Yup
Pobiega
Pobiega11mo ago
works? errors?
Kiragi
KiragiOP11mo ago
No errors Hopefully it works now
Pobiega
Pobiega11mo ago
okay, then its likely a ghost error, meaning VS cached the error and missed that you fixed it
Kiragi
KiragiOP11mo ago
It works IT WORKSSS Thank you 👍🏼
Pobiega
Pobiega11mo ago
np
Want results from more Discord servers?
Add your server