[英]System.ArgumentException: 'Parameter is not valid.' (showDialog error)
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. 我是C#的新手,我正在尝试编码一个页面,在其中选择一个按钮会将图像及其文本传递到另一页面,但是,它向我显示了此错误。 (I was having an error with the code in Stars) Sorry i am still new to this soo i dont get what it means.
(我在Stars中的代码有错误)对不起,我还是这个新手,所以我不明白它的意思。
An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll Parameter is not valid. System.Drawing.dll中发生了类型为'System.ArgumentException'的未处理异常。参数无效。
(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:
您应该创建两个-一个是默认值:
public Booking()
{
InitialiseComponent();
}
And the second constructor is whatever you'd like to: 第二个构造函数是您想要的:
public Booking(Image passingimage, string bandtitle)
{
InitialiseComponent();
//Your code goes here
}
That's so because the program launches the Form without any arguments. 之所以这样,是因为该程序将启动不带任何参数的Form。 So you have to edit the first code so it has two constructors:
因此,您必须编辑第一个代码,使其具有两个构造函数:
public Booking()
{
InitialiseComponent();
}
public Booking(Image passingimage, string bandtitle)
{
InitialiseComponent();
//Your code goes here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.