dataGridView1_CellClick事件怎样激活?
dataGridView1_CellContentClick事件又怎样激活?
这两个有深区别?为什么添加代码不管用呢?
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            txtRoomName.Text = dataGridView1.SelectedCells[0].Value.ToString();
            txtRooJC.Text = dataGridView1.SelectedCells[1].Value.ToString();
            txtBJF.Text = dataGridView1.SelectedCells[2].Value.ToString();
            txtRoomWZ.Text = dataGridView1.SelectedCells[3].Value.ToString();
            txtRoomZT.Text = dataGridView1.SelectedCells[4].Value.ToString();
            txtRoomType.Text = dataGridView1.SelectedCells[5].Value.ToString();
            txtQT.Text = dataGridView1.SelectedCells[6].Value.ToString();
            txtBZ.Text = dataGridView1.SelectedCells[7].Value.ToString();
        }            
这样有用吗???为什么运行的时候点击dataGridView不管用呢?各textBox什么都不显示郁闷、、、

解决方案 »

  1.   

    dataGridView1_CellClick
    此事件在单元格的任何部分(包括边框和空白)被单击时发生。当按钮单元格或复选框单元格具有焦点时,此事件还在用户按下并松开空格键时发生;如果在按下空格键的同时,该单元格被单击,此事件将针对这些类型的单元格发生两次。 
      

  2.   


    dataGridView1_CellContentClick在单元格内容被单击时发生此事件。当按钮单元格或复选框单元格具有焦点时,此事件还在用户按下并松开空格键时发生;如果在按下空格键的同时,该单元格的内容被单击,此事件将针对这些类型的单元格发生两次。
    参考
    参考
     
      

  3.   

       private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                if (e.RowIndex >= 0)
                {
                    txtRoomName.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                    txtRooJC.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); 
                    txtBJF.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                 }
            }
      

  4.   

    .
    点是当然的了,dataGridView的那个光标一直跟着点击的移动,可就是不执行那个事件
      

  5.   

    privatevoid dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) 
    改为privatevoid dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) 解决了
      

  6.   

    主要看一下你的 form.cs  点前面的 + 号,,会展开   里面有 for.designer.cs   这个里面包含的有窗体的所有事件,,
    你看看  datagridview中有没有   this.CellClick    
    如果没有,,自己添加就可以了 写 this.CellClick +=   然后他会自己提示一个好长的new system.windows.form........(在括号中写上你在页面上所要出发的事件,比如:  datagridview1_CellClick);
    这样就会触发等号前面的事件