C
C#10mo ago
Ninja Kirby

✅ WinForms - Parameter is not valid?

for whatever reason, my custom control 'SimonButton' breaks in the OnPaint method
No description
13 Replies
Ninja Kirby
Ninja KirbyOP10mo ago
No description
Ninja Kirby
Ninja KirbyOP10mo 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
SinFluxx10mo 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 User10mo ago
Message Not Public
Sign In & Join Server To View
Ninja Kirby
Ninja KirbyOP10mo 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 User10mo ago
Message Not Public
Sign In & Join Server To View
Ninja Kirby
Ninja KirbyOP10mo ago
wow it worked epic
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Ninja Kirby
Ninja KirbyOP10mo ago
i used a debugger i verified the validity of the statement
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Ninja Kirby
Ninja KirbyOP10mo ago
and the error message wasnt real to me at all 💀
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Ninja Kirby
Ninja KirbyOP10mo ago
no line or indication that i should call base but its solved now
Want results from more Discord servers?
Add your server