C# 单击datagridview中的数据,然后将数据传递到弹出窗口

C# 单击datagridview中的数据,然后将数据传递到弹出窗口,c#,datagridview,C#,Datagridview,我只是想问,当我想通过单击DataGridView中的列将数据传递到弹出窗口时,我将如何编码。请帮忙 try { Lessee_Message frm = new Lessee_Message( dataGridView1.CurrentRow.Cells["ID"].Value.ToString())); frm .ShowDialog(); } catch(Exception a) { } 此代码有什么问题?您必须在消息表单中创建一个重载构造函数,才能将字

我只是想问,当我想通过单击
DataGridView
中的
将数据传递到弹出窗口时,我将如何编码。请帮忙

try
{
    Lessee_Message frm = new Lessee_Message(
        dataGridView1.CurrentRow.Cells["ID"].Value.ToString())); 
    frm .ShowDialog();
}
catch(Exception a) { }

此代码有什么问题?

您必须在消息表单中创建一个重载构造函数,才能将字符串作为参数传递

承租人信息应具有如下内容:

public partial class Lessee_Message : Form
{    
//This is only for further use. only to pass a parameter, the private field is not required.
private string _id="";
 public Lessee_Message (string id)
 {
_id=id;
 InitializeComponent ();
 }

}

此代码承租人消息frm=新承租人消息(dataGridView1.CurrentRow.Cells[“ID”].Value.ToString());始终为红线,并且首先出现一个错误,即“承租人消息不接受超过1个参数”:您有一个
超出您需要的
新承租人消息(dataGridView1.CurrentRow.Cells[“ID”].Value.ToString())您在
承租人消息
类中有哪些构造函数?