Scenario:
I have a grid that shows student names etc. It has a child grid that lists all the tests for that particular student. The parent grid has CommandCellColumn where the user can launch a report that has a summary of all the students tests, the child grid has a CommandCellColumn that launches a report for the individual test.
Problem:
You click on the 'Print Summary' button on the parent grid, it launches the report, view the report, close the report window. Everything is fine. Click on the 'Print Results' button in the child grid, view the report, close the window. It will close the window, the will open the same window again. You close the newly opened window, and after closing that one, it won't happen again. I'm guessing that since I'm usign the Form.ShowDialog() to open the report windows, its holding the sencond window back for whatever reason. I don't know why, but the child grid always opens a second form.
I tried to put some flags in the event the stop the code from executing twice, but it didn't work.
The Code:
private
void grvStudentTestResults_CommandCellClick(object sender, EventArgs e)
{
if (stop == 0)
{
stop = 1;
GridCommandCellElement element = sender as GridCommandCellElement;
if (element.ColumnInfo.HeaderText == "Testing Summaries")
{
frmResults frm = new frmResults(Convert.ToInt32(element.RowInfo.Cells["StudentID"].Value));
frm.ShowDialog();
stop = 0;
}
else if (element.ColumnInfo.HeaderText == "Print Results")
{
frmResults frm = new frmResults(Convert.ToInt32(element.RowInfo.Cells["StudentID"].Value), element.RowInfo.Cells["TestCode"].Value.ToString());
frm.ShowDialog();
stop = 0;
}
}
}