Example #1
0
        private void HorizontalLinesDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            // if the click occurred on a data grid view row (not on the header) and on the delete horizontal marker column
            if (e.RowIndex >= 0 && e.ColumnIndex == ChartHorizontalLinesDeleteColumn.Index)
            {
                DataGridViewRow clickedRow = HorizontalLinesDataGridView.Rows[e.RowIndex];

                // assemble arguments to pass to remove horizontal line method
                Line   l           = clickedRow.DataBoundItem as Line;
                double yCoordinate = Convert.ToDouble(clickedRow.Cells[ChartHorizontalLinesYColumn.Name].Value);

                // remove horizontal line from metadata and remove grid view row
                Metadata.RemoveHorizontalLine(yCoordinate, l.Coordinate.AxisTitle);
                HorizontalLinesDataGridView.Rows.Remove(clickedRow);

                ChartForm.ChartMetadataSaveRequired(Metadata);

                // set the current cell to the cell in the first column of the first visible row
                int firstVisibleRowIndex = HorizontalLinesDataGridView.Rows.GetFirstRow(DataGridViewElementStates.Visible);
                if (firstVisibleRowIndex != -1)
                {
                    HorizontalLinesDataGridView.CurrentCell = HorizontalLinesDataGridView[0, firstVisibleRowIndex];
                }
            }
        }
Example #2
0
        private void NoteDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            // if the click occurred on a data grid view row (not on the header) and on the delete chart note column
            if (e.RowIndex >= 0 && e.ColumnIndex == ChartNoteDeleteColumn.Index)
            {
                DataGridViewRow clickedRow = NoteDataGridView.Rows[e.RowIndex];

                // assemble arguments to pass to remove note method
                Note   n           = clickedRow.DataBoundItem as Note;
                double xCoordinate = Convert.ToDouble(clickedRow.Cells[ChartNoteXColumn.Name].Value);
                double yCoordinate = Convert.ToDouble(clickedRow.Cells[ChartNoteYColumn.Name].Value);

                // remove vertical line from metadata and remove grid view row
                Metadata.RemoveChartNote(xCoordinate, n.XCoordinate.AxisTitle, yCoordinate, n.YCoordinate.AxisTitle, n.MarkColor, n.NoteText);
                NoteDataGridView.Rows.Remove(clickedRow);

                ChartForm.ChartMetadataSaveRequired(Metadata);

                // set the current cell to the cell in the first column of the first visible row
                int firstVisibleRowIndex = NoteDataGridView.Rows.GetFirstRow(DataGridViewElementStates.Visible);
                if (firstVisibleRowIndex != -1)
                {
                    NoteDataGridView.CurrentCell = NoteDataGridView[0, firstVisibleRowIndex];
                }
            }
        }