0

我是 c# 的新手,我正在尝试编写一个页面,在该页面中选择一个按钮,它将图像及其文本传递到另一个页面,但是,它向我显示了这个错误。(我在 Stars 中的代码有错误)对不起,我还是新手,所以我不明白这意味着什么。

System.Drawing.dll 参数中出现“System.ArgumentException”类型的未处理异常无效。

(第一个代码是要插入的图像和消息)

(第二个代码用于将图像和消息插入到第一个代码中)

这是第一个代码

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();**
}

第二代码

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);
  }
}
4

1 回答 1

0

您不能创建带有参数的构造函数,至少只有一个。您应该创建两个 - 一个是默认值:

public Booking()
{
    InitialiseComponent();
}

第二个构造函数是您想要的任何东西:

public Booking(Image passingimage, string bandtitle)
{
    InitialiseComponent();
    //Your code goes here
}

之所以如此,是因为程序在没有任何参数的情况下启动了表单。所以你必须编辑第一个代码,让它有两个构造函数:

public Booking()
{
    InitialiseComponent();
}

public Booking(Image passingimage, string bandtitle)
{
    InitialiseComponent();
    //Your code goes here
}
于 2018-11-03T07:57:52.903 回答