简体   繁体   English

System.ArgumentException:'参数无效。 (showDialog错误)

[英]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.

相关问题 System.ArgumentException:参数无效。 GraphicsPath.AddString - System.ArgumentException: Parameter is not valid. GraphicsPath.AddString System.ArgumentException:参数无效。 在C#中 - System.ArgumentException: Parameter is not valid. in C# System.ArgumentException:参数无效 - System.ArgumentException: Parameter is not valid C#System.ArgumentException:参数无效。 在System.Drawing.Bitmap..ctor(Stream stream) - C# System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Stream stream) Windows窗体:“ System.ArgumentException:参数无效。”来自系统堆栈 - Windows Forms: “System.ArgumentException: Parameter is not valid.” coming from System stack System.ArgumentException HResult = 0x80070057 消息 = 参数无效。 来源 = System.Drawing。 为什么? - System.ArgumentException HResult = 0x80070057 Message = Parameter is not valid. Source = System.Drawing. Why? 给出“System.ArgumentException:'参数无效。' " 当我从数据库中检索图像时 - Gives "System.ArgumentException: 'Parameter is not valid.' " when i retrieving image from database System.ArgumentException:“参数无效。” 在 C# 中从 SQL Server 获取图像 - System.ArgumentException: 'Parameter is not valid.' in C# get image from SQL Server 更新 Access 数据库后检索图像时出现问题(System.ArgumentException:'参数无效。') - Problem retrieving the image after updating the Access database (System.ArgumentException: 'Parameter is not valid.') ImageResizer-转换PSD文件时出错-System.ArgumentException:参数无效 - ImageResizer - Error converting PSD file - System.ArgumentException: Parameter is not valid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM