簡體   English   中英

在datagridview中單擊數據,然后將數據傳遞到彈出窗口

[英]clicking data in datagridview then passing the data to popup window

我只想問一下,當我想通過單擊DataGridView的“ Column將數據傳遞到彈出窗口時如何編碼。 請幫忙!

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

此代碼有什么問題?

您必須以Lessee_Message形式創建重載的構造函數,才能將字符串作為參數傳遞。

Lessee_Message應該具有以下內容:

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

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM