//dataGridView1.Rows[0].Selected = false; //放在Form1這里不起效果 可放在下面的Form1_Load中 this.button1.Focus(); } private void Form1_Load(object sender, EventArgs e) { dataGridView1.Rows[0].Selected = false; //this.dataGridView1.TabStop = false; //dataGridView1.Rows[0].Selected = false; //this.dataGridView1.CurrentCell = null; //dataGridView1.ClearSelection(); }
搜到重點 ,放上來
MessageBox.Show(dgvPo.Rows[0].Selected.ToString());
MessageBox.Show(dgvPo.CurrentRow.Index.ToString());
彈出來的是Flase,0
說明它沒被選中,但是它是當前行
MessageBox.Show(dgvPo.Rows[0].Selected.ToString());
MessageBox.Show(dgvPo.CurrentRow.Index.ToString());
彈出來的是Flase,0
說明它沒被選中,但是它是當前行
Selected = true只是讓這個單元格被選中,不代表當前單元格就變成它了