问题
I am setting the current row using the following code
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;
}
In my second form which has a back button.
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();
}
Now the databindind in the first form works well . but at Program.fPlant.Show(), rowselection reverts to the default(first row), but I need it maintain selected row
来源:https://stackoverflow.com/questions/10761154/form-show-causing-to-loose-row-selection