CS0123 - No overload for 'Form1_Load' matches delegate 'EventHandler after adding PaintEventArgs

  • Thread starter Thread starter Yuvi105
  • Start date Start date
Y

Yuvi105

Guest
Im trying to figure this out without any success, i have a good working code (for arduino),

and after adding PaintEventArgs g inside Form1_load in order to add two shapes, i get this error message:

"CS0123 - No overload for 'Form1_Load' matches delegate 'EventHandler after adding PaintEventArgs.

Can someone please suggest ?

Thanks !

The code:


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.Threading;

namespace Arduino
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

// Pen for border color
Pen red = new Pen(Color.Red);
Pen green = new Pen(Color.Green);
// To fill shape
System.Drawing.SolidBrush fillRed = new System.Drawing.SolidBrush(Color.Red);
System.Drawing.SolidBrush fillGreen = new System.Drawing.SolidBrush(Color.Green);

Rectangle rect = new Rectangle(20, 100, 20, 20); // X, y, width, height
Rectangle circle = new Rectangle(60, 100, 20, 20); // X, y, width, height


private void Form1_Load(object sender, PaintEventArgs g, EventArgs e)
{

Graphics f = g.Graphics;
f.DrawRectangle(red, rect); // Draw rectangle
f.DrawEllipse(green, circle); // Draw circle

f.FillRectangle(fillRed, rect); // Fill rectangle
f.FillRectangle(fillGreen, circle); // Fill



try
{
//When Form1 loads it grabs the serial port and put it in the portbox
PortBox.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames());
//Automatically put the first index into the portbox
PortBox.SelectedIndex = 0;

serialPort1.BaudRate = (9600);
serialPort1.ReadTimeout = (2000);
serialPort1.WriteTimeout = (2000);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

bool Delay = false;
int i;

private void textBox1_TextChanged(object sender, EventArgs e)
{

i = int.Parse(textBox1.Text);
}



private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Delay = true;
}


private void OnButton_Click(object sender, EventArgs e)
{
try
{
serialPort1.Open();
serialPort1.WriteLine("on");

if (Delay)
{
OnButton.Enabled = false;
Thread.Sleep(i*1000);
serialPort1.WriteLine("off");
serialPort1.Close();

DelayCheckBox.Checked = false;
OnButton.Enabled = true;
OffButton.Enabled = true;
Delay = false;

}
else
{
Delay = false;
serialPort1.Close();
DelayCheckBox.Checked = false;
OnButton.Enabled = false;
OffButton.Enabled = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void OffButton_Click(object sender, EventArgs e)
{
try
{
serialPort1.Open();
serialPort1.WriteLine("off");
serialPort1.Close();

OnButton.Enabled = true;
OffButton.Enabled = false;

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void PortBox_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
serialPort1.PortName = PortBox.Text;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void label1_Click(object sender, EventArgs e)
{

}
}
}

Continue reading...
 
Back
Top