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;
}

戻るボタンがある私の2番目のフォーム。

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() では、行選択はデフォルト (最初の行) に戻りますが、選択された行を維持する必要があります

4

0 に答える 0