你是想让DatagridView第一行获得焦点还是想执行dataGridView1_CellClick事件
//DatagridView第一行获得焦点
private void button1_Click(object sender, EventArgs e)
{
dataGridView1[0, 0].Selected = true;
}
//执行dataGridView1_CellClick事件
private void button1_Click(object sender, EventArgs e)
{
DataGridViewCellEventArgs dataGridViewCellEventArgs = new DataGridViewCellEventArgs(0, 0);
dataGridView1_CellClick(dataGridView1, dataGridViewCellEventArgs);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show("列:" + e.ColumnIndex + "\n" + "行:" + e.RowIndex);
}
据我所知,只要你选择了selectfullrows这一项,近件在启动以后就会自动选中第一个单元格