I am new to c#, I am trying to code a page where select a button it will pass the image and its text to the other page, however, it shows me this error. (I was having an error with the code in Stars) Sorry i am still new to this soo i dont get what it means.
An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll Parameter is not valid.
(The first code was the image and message to be inserted)
(The second code was for the image and message to be inserted into the first code)
This the first Code
public Booking(Image passingimage, string bandtitle)
{
InitializeComponent();
pictureBox1.Image = passingimage;
bunifuCustomLabel5.Text = bandtitle;
}
public static void Shbooking(string bandtitle, Image passingimage)
{
Booking bk = new SoftwarePrj_LawZhiMing.Booking (passingimage,bandtitle);
**bk.ShowDialog();**
}
Second Code
public partial class EandB : UserControl
{
Image passingimage;
public static string passingtitle;
private void BunifuThinButton21_Click_1(object sender, EventArgs e)
{
((Home)this.TopLevelControl).Hide();
passingimage = pictureBox6.Image;
passingtitle = bunifuCustomLabel2.Text;
Booking.Shbooking(passingtitle, passingimage);
}
}
You cannot create a constructor with arguments, at least only one. You shoud create two - one is the default:
And the second constructor is whatever you'd like to:
That's so because the program launches the Form without any arguments. So you have to edit the first code so it has two constructors: