比如我想把datagirdview的第三行设成当前行怎么写代码?
不要发送键盘按键的.

解决方案 »

  1.   

    // 设置选择某一个cell 时 显示选择整行。
    dataGridView_mydg.SelectionMode = DataGridViewSelectionMode.FullRowSelect;// 设置第三行为当前行。
    dataGridView_mydg.CurrentCell = dataGridView_mydg.Rows[2].Cells[0];
      

  2.   

    也可以这样!
    this.dataGridView1.CurrentCell = this.dataGridView1.Rows[2].Cells[0];
    this.dataGridView1.Rows[2].Selected=true;
      

  3.   

    学习datagridview
    dataGridView1_mydg.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    this.dataGridView1.Rows[2].Selected=true;
      

  4.   

    private void drugListDataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
            {
               
                
                if (e.Button == MouseButtons.Right)
                {    
                    System.Console.WriteLine(e.RowIndex);
                    int curRow = e.RowIndex;
                    if (curRow < 0 || curRow > this.drugListDataGridView.Rows.Count)
                    {
                        curRow = 0;
                    }
                     this.drugListDataGridView.CurrentCell.Selected=false;
                     this.drugListDataGridView.CurrentCell = this.drugListDataGridView[0, curRow];
                   
                     this.drugListDataGridView.ContextMenuStrip=this.contextMenuStrip1;
                }
            }
      

  5.   

    dataGridView1.Rows[1].Selected = true;
      

  6.   

    this.drugListDataGridView.CurrentCell = this.drugListDataGridView[0, curRow];
      

  7.   

    1楼的没错//设置第3行为当前行
    dataGridView1.CurrentCell = datagirdview.Rows[3].Cells[0];问题是你是否要获取当前行,到底是怎样无法实现