[12141] | 1 | #region License Information
|
---|
| 2 |
|
---|
| 3 | /* HeuristicLab
|
---|
[14185] | 4 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[12141] | 5 | *
|
---|
| 6 | * This file is part of HeuristicLab.
|
---|
| 7 | *
|
---|
| 8 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 9 | * it under the terms of the GNU General Public License as published by
|
---|
| 10 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 11 | * (at your option) any later version.
|
---|
| 12 | *
|
---|
| 13 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 16 | * GNU General Public License for more details.
|
---|
| 17 | *
|
---|
| 18 | * You should have received a copy of the GNU General Public License
|
---|
| 19 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | #endregion
|
---|
| 23 |
|
---|
| 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.Data.Views;
|
---|
| 26 | using HeuristicLab.MainForm;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
| 29 | [View("ModifiableDataset View")]
|
---|
| 30 | [Content(typeof(ModifiableDataset), true)]
|
---|
| 31 | public partial class ModifiableDatasetView : StringConvertibleMatrixView {
|
---|
| 32 | public new ModifiableDataset Content {
|
---|
| 33 | get { return (ModifiableDataset)base.Content; }
|
---|
| 34 | set {
|
---|
| 35 | if (base.Content != value)
|
---|
| 36 | base.Content = value;
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | public ModifiableDatasetView() {
|
---|
| 41 | InitializeComponent();
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | #region register/deregister content events
|
---|
| 45 | protected override void RegisterContentEvents() {
|
---|
| 46 | base.RegisterContentEvents();
|
---|
| 47 | dataGridView.CellContentDoubleClick += dataGridView_cellContentDoubleClicked;
|
---|
| 48 | dataGridView.CellLeave += dataGridView_cellLeave;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | protected override void DeregisterContentEvents() {
|
---|
| 52 | dataGridView.CellContentDoubleClick -= dataGridView_cellContentDoubleClicked;
|
---|
| 53 | dataGridView.CellLeave -= dataGridView_cellLeave;
|
---|
| 54 | base.DeregisterContentEvents();
|
---|
| 55 | }
|
---|
| 56 | #endregion
|
---|
| 57 |
|
---|
| 58 | #region event handlers
|
---|
| 59 | private void dataGridView_cellContentDoubleClicked(object sender, DataGridViewCellEventArgs args) {
|
---|
| 60 | var currentCell = dataGridView[args.ColumnIndex, args.RowIndex];
|
---|
| 61 | dataGridView.ReadOnly = false;
|
---|
| 62 | currentCell.ReadOnly = false;
|
---|
| 63 | dataGridView.CurrentCell = currentCell;
|
---|
| 64 | dataGridView.BeginEdit(true);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | private void dataGridView_cellLeave(object sender, DataGridViewCellEventArgs args) {
|
---|
| 68 | var currentCell = dataGridView[args.ColumnIndex, args.RowIndex];
|
---|
| 69 | dataGridView.ReadOnly = true;
|
---|
| 70 | currentCell.ReadOnly = true;
|
---|
| 71 | dataGridView.EndEdit();
|
---|
| 72 | }
|
---|
| 73 | #endregion
|
---|
| 74 | }
|
---|
| 75 | }
|
---|