2011-05-21 67 views

回答

0

試試這個

private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) 
     { 
      try 
      { 
       Form1 frm = new Form1(DataGridView1.CurrentRow.Cells["ID"].Value.ToString())); 
       frm .ShowDialog(); 

      } 
      catch (Exception ex) 
      { 
      } 

     } 

在此代碼ü要顯示爲彈出另一種形式的創建對象。 // Form1 frm = new Form1.

而且考取ID值作爲構造函數的形式Form1並顯示爲對話// DataGridView1.CurrentRow.Cells["ID"].Value

也將Form 1 ShowInTaskBar屬性來False

注:

您可以訪問該構造函數值(ID)從Form1並獲取所有詳細信息ID並顯示爲你的願望

+0

私人無效DataGridView_CellClick(對象發件人,DataGridViewCellEventArgs E) { 嘗試 { Viewaddeduser FRM =新Viewaddeduser(DataGridView.CurrentRow .Cells [ 「FileNo在」] Value.ToString());。 frm .ShowDialog(); } catch(Exception ex) { MessageBox.Show(「Ok」+ ex); } } – 2011-05-21 11:38:33

+0

它給出異常 – 2011-05-21 11:38:45

+0

和viewadded用戶表單private String FileNo; public Viewaddeduser(String FileNo) { InitializeComponent(); } 它是正確的方式? – 2011-05-21 11:39:39

1

你可以嘗試這樣的:

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) 
    { 
     String info; 

     if (e.ColumnIndex == 0) // Here specify the column index on click of which you want to display popup 
     { 
      //your logic here 
      info= dataGridView1.Rows[e.RowIndex].Cells["U_ID"].Value).toString(); // Cells["<specify your cell name for this index>"] 
      MessageBox.Show(info); 
     } 

     else if (e.ColumnIndex == 1) // Here specify the column index on click of which you want to display popup 
     { 
      //your logic here 
      info= dataGridView1.Rows[e.RowIndex].Cells["Name"].Value).toString(); // Cells["<specify your cell name for this index>"] 
      MessageBox.Show(info); 
     } 
    } 

MSDN

相關問題