vs2005里做一个记录浏览列表,用datagridview,鼠标点击不同的记录行,下面对应的textbox值能相应改变
我用的datagridview的dataGridView1_CellContentClick和dataGridView1_CurrentCellChanged方法,都只有鼠标准确点击在cell里的值上面,才会触发事件,点在cell的空白处,或行头则没反应
想要使鼠标点击在这行的任意地方都能触发事件怎么做

解决方案 »

  1.   

    DataGridView1_SelectionChanged事件试试
      

  2.   

    有没有知道哪有全面的DataGridView用法!!!!
      

  3.   

    需要DareGridView里的SelectionMode的属性改成FullRowSelect这样试下行么
      

  4.   

            private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
            {        }
    用这个事件应该可以。
      

  5.   

    1.将dataGridView的MultiSelect属性改为false2.添加dataGridView的click事件代码:
     private void dataGridView_Click(object sender, EventArgs e)
            {
                if (dataGridView.SelectedRows.Count > 0)
                {
                    
                    string str = dataGridView.SelectedRows[0].Cells[0].Value.ToString();//这里获取单元格里面的值,你可以改一下
                    textBox1.Text=str;             }
                
            }
      

  6.   

    你的事件使用错了,应该使用dataGridView1_CellClick事件。这个是单元格被点击事件,你用的那个是单元格中的内容被点击事件。两个不一样,很容易疏忽,我也遇到过,:)
      

  7.   

    呵呵是使用dataGridView1_CellClick事件的.
    Eg;
     private void dgvUserInfo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
                txtName.Text = Convert.ToString(dgvAreaInfo[0, dgvAreaInfo.CurrentCell.RowIndex].Value).Trim();
                txtAddress.Text = Convert.ToString(dgvAreaInfo[1, dgvAreaInfo.CurrentCell.RowIndex].Value).Trim();
                }