Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/ModifiableDatasetView.cs @ 14099

Last change on this file since 14099 was 12509, checked in by mkommend, 9 years ago

#2276: Reintegrated branch for dataset refactoring.

File size: 2.6 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
24using System.Windows.Forms;
25using HeuristicLab.Data.Views;
26using HeuristicLab.MainForm;
27
28namespace 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}
Note: See TracBrowser for help on using the repository browser.