我怎么能加载与DataGrid中单击单元格形式

我怎么能加载与DataGrid中单击单元格形式

问题描述:

大家好,我会在我的DataGrid中一些数据如下alt text我怎么能加载与DataGrid中单击单元格形式

现在,如果我在第一栏点击任意单元格我想从显示,如果我点击任何单元格值的第二行,我想显示另一种形式。我怎样才能做到这一点...

我得到了答案

 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) 
    { 
     string s = dataGridView1.CurrentCell.RowIndex.ToString(); 
     if (Convert.ToInt32(s) == 0) 
     { 
      Form f = new Form(); 
      ActivateMdiChild(f); 
      f.Show(); 
     } 
     if (Convert.ToInt32(s) == 1) 
     { 
      MessageBox.Show("Hi"); 
     } 
    } 

你需要在数据表(或隐藏的列)中保留一些要启动的值标识表单。现在,在点击事件中,您可以在当前行内查找该值并启动所需的表单。