0

我正在使用以下代码设置当前行

private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
    gSelectedPlant = StaticClass.GlobalValue;

    dataGridView1.CurrentCell = dataGridView1.Rows[gSelectedPlant].Cells[0];
    dataGridView1.Rows[gSelectedPlant].Selected = true;
    gSelectedPlant = dataGridView1.CurrentCell.RowIndex;
}

在我的第二种形式中,它有一个后退按钮。

private void btnCancel_Click(object sender, EventArgs e)
{
    int plantid = StaticClass.GlobalValue;
    //Properties.Settings.Default.PlantId = plantid;

    Program.fPlant = new frmPlant(plantid);
    Program.fPlant.Show();
    this.Hide();

 }

现在第一种形式的数据绑定运行良好。但是在 Program.fPlant.Show() 中,rowselection 恢复为默认值(第一行),但我需要它保持选定的行

4

0 回答 0