✅ WinForms - Parameter is not valid?

for whatever reason, my custom control 'SimonButton' breaks in the OnPaint method
No description
13 Replies
Bandana Dee(z)
Bandana Dee(z)4mo ago
No description
Bandana Dee(z)
Bandana Dee(z)4mo ago
protected override void OnPaint(PaintEventArgs e)
{
if (_isClicked)
{
e.Graphics.DrawImage(new Bitmap($"{AppDomain.CurrentDomain.BaseDirectory}Simon-Assets\\YellowDown.png"), Location.X, Location.Y);
}
else
{
e.Graphics.DrawImage(new Bitmap($"{AppDomain.CurrentDomain.BaseDirectory}Simon-Assets\\Yellow.png"), Location.X, Location.Y);
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (_isClicked)
{
e.Graphics.DrawImage(new Bitmap($"{AppDomain.CurrentDomain.BaseDirectory}Simon-Assets\\YellowDown.png"), Location.X, Location.Y);
}
else
{
e.Graphics.DrawImage(new Bitmap($"{AppDomain.CurrentDomain.BaseDirectory}Simon-Assets\\Yellow.png"), Location.X, Location.Y);
}
}
SinFluxx
SinFluxx4mo ago
Note sure if it will solve the error you're seeing, but from the docs: Notes to Inheritors When overriding OnPaint(PaintEventArgs) in a derived class, be sure to call the base class's OnPaint(PaintEventArgs) method so that registered delegates receive the event.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Bandana Dee(z)
Bandana Dee(z)4mo ago
i verified the validity of the actual path it is correct and does lead to a file and i am aware that is what he means so i will try it
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Bandana Dee(z)
Bandana Dee(z)4mo ago
wow it worked epic
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Bandana Dee(z)
Bandana Dee(z)4mo ago
i used a debugger i verified the validity of the statement
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Bandana Dee(z)
Bandana Dee(z)4mo ago
and the error message wasnt real to me at all 💀
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Bandana Dee(z)
Bandana Dee(z)4mo ago
no line or indication that i should call base but its solved now