2011-05-21 69 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

相关问题