private void toolVisual_Click(object sender, EventArgs e) { if (gridMark.SelectedRows == null) { Core.Utility.Msg("Hãy chọn dòng mà bạn muốn hiển thị bài làm trực quan"); return; } DataGridViewRow row = gridMark.SelectedRows[0]; gridMark.FirstDisplayedCell = row.Cells[0]; // tránh người dùng thay đổi khi đã vào chế độ visualizer //row.Frozen = true; FormKeyVisualize visualizer = new FormKeyVisualize(); Hashtable tag = visualizer.Tag as Hashtable; MarkRowInfo rowtag = (MarkRowInfo)row.Tag; tag.Add(FormKeyVisualize.TagKeys.Answer, (string)row.Cells["colDetail"].Value); tag.Add(FormKeyVisualize.TagKeys.Questions, _keys.questions); tag.Add(FormKeyVisualize.TagKeys.Column, -1); visualizer.rowIndex = rowtag.GridIndex; visualizer.FormClosing += new FormClosingEventHandler(visualizer_FormClosing); visualizer.MdiParent = this.MdiParent; visualizer.Top = this.Top; visualizer.Left = this.Left + this.Width; visualizer.StartPosition = FormStartPosition.Manual; visualizer.Show(); }
void visualizer_FormClosing(object sender, FormClosingEventArgs e) { try { FormKeyVisualize visualizer = (FormKeyVisualize)sender; DataGridViewRow row = gridMark.Rows[visualizer.rowIndex]; //row.Frozen = false; // Bỏ chọn cũ gridMark.ClearSelection(); // Chọn riêng ô Detail row.Cells[colDetail.Index].Selected = true; gridMark.BeginEdit(false); row.Cells[colDetail.Index].Selected = false; row.Cells[colDetail.Index].Value = visualizer.returnAns; gridMark.EndEdit(); gridMark.InvalidateCell(row.Cells[colDetail.Index]); // Tính lại kết quả. //gridMark_CellValueChanged( // visualizer, // new DataGridViewCellEventArgs(colDetail.Index, gridMark.SelectedRows[0].Index)); // Chọn lại dòng gridMark.ClearSelection(); // Cách để nó "refresh" cho mình sau khi Visualize gridMark.FirstDisplayedCell = row.Cells[0]; row.Cells[colMark.Index].Selected = true; gridMark.BeginEdit(false); gridMark.EndEdit(); row.Selected = true; } catch (Exception ex) { Core.Utility.Msg("Bạn thao tác chưa đúng. Xin vui lòng xin lại chỉ dẫn" + ex.Message); return; } }
private void btnVisual_Click(object sender, EventArgs e) { if (gridProblems.SelectedCells.Count == 0) { return; } DataGridViewCell cell = gridProblems[1, gridProblems.SelectedCells[0].RowIndex]; //if (cell.ColumnIndex == 1) { this.Enabled = false; FormKeyVisualize visualizer = new FormKeyVisualize(); Hashtable tag = visualizer.Tag as Hashtable; tag.Add(FormKeyVisualize.TagKeys.Answer, cell.Value == null ? "" : (string)cell.Value); tag.Add(FormKeyVisualize.TagKeys.Questions, (int)numQuestions.Value); tag.Add(FormKeyVisualize.TagKeys.Column, cell.ColumnIndex); tag.Add(FormKeyVisualize.TagKeys.Row, cell.RowIndex); visualizer.FormClosing += new FormClosingEventHandler(visualizer_FormClosing); visualizer.MdiParent = this.MdiParent; visualizer.Top = this.Top; visualizer.Left = this.Left + this.Width; visualizer.StartPosition = FormStartPosition.Manual; visualizer.Show(); } }