【发布时间】:2013-05-31 10:29:10
【问题描述】:
我在双击 DataGridViewRow 时打开了一个 MDI 子项。在 MDI 子项中显示了此选定行的值。其中一个值显示在组合框中。当我打开第一个 MDI 子时一切顺利,组合框显示正确的值(正确的控制台)。
但是,当我从 DataGridView 中选择另一行打开类似的第二个 MDI 子项时,第一个 MDI 子项中的组合框值更改为必须在第二个 MDI 子项中显示的值。第一个 MDI 子窗体中的所有其他文本框值仍然正确显示。
有人有解决这个问题的办法吗?
MDI 父窗体
private void dataGridViewGames_DoubleClick(object sender, EventArgs e)
{
FormGame formGame = new FormGame();
formGame.MdiParent = this.MdiParent;
formGame.Name = dataGridViewGames.SelectedRows[0].Index.ToString();
formGame.Rij = dataGridViewGames.SelectedRows[0].Index;
formGame.Consoles = consoles;
formGame.Games = games;
formGame.Show();
formGame.LeesGame();
}
MDI 子窗体
private void FormGame_Load(object sender, EventArgs e)
{
comboBoxConsole.DataSource = consoles;
comboBoxConsole.DisplayMember = "Naam";
comboBoxConsole.ValueMember = "Id";
}
public void LeesGame()
{
DBGames.GameRow gameRij = (DBGames.GameRow)games.Rows[rij];
this.Text = "Game - " + gameRij.Naam;
textBoxNaam.Text = gameRij.Naam;
textBoxPrijs.Text = gameRij.Prijs.ToString();
textBoxAfbeelding.Text = gameRij.Afbeelding;
comboBoxConsole.SelectedValue = gameRij.ConsoleId;
}
【问题讨论】:
标签: c# datagridview combobox mdi