Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/26/14 15:25:37 (11 years ago)
Author:
rstoll
Message:

Change CTRL+F and CTRL+R to be executed when key down (is more usability friendly)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs

    r10659 r10668  
    6262      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
    6363      dataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting);
    64       dataGridView.KeyUp += dataGridView_KeyUp;
     64      dataGridView.KeyDown += dataGridView_KeyDown;
    6565      contextMenuCell.Items.Add(ShowHideColumns);
    6666      _highlightedCells = new Dictionary<int, IList<int>>();
     
    138138    }
    139139
    140     private void dataGridView_KeyUp(object sender, KeyEventArgs e) {
    141       var selectedRows = dataGridView.SelectedRows;
    142       if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
    143         List<int> rows = new List<int>();
    144         for (int i = 0; i < selectedRows.Count; ++i) {
    145           rows.Add(selectedRows[i].Index);
    146         }
    147         triggersOwnEvent(() => {
    148           Content.DataGridLogic.DeleteRow(rows);
    149           OnContentChanged();
    150         });
    151       } else if (e.Control && e.KeyCode == Keys.F) {
    152         CreateFindAndReplaceDialog();
    153         findAndReplaceDialog.ActivateSearch();
    154       } else if (e.Control && e.KeyCode == Keys.R) {
    155         CreateFindAndReplaceDialog();
    156         findAndReplaceDialog.ActivateReplace();
    157       }
    158     }
     140
    159141
    160142    private void CreateFindAndReplaceDialog() {
     
    227209        e.Graphics.FillRectangle(backColorBrush, bounds);
    228210      }
    229 
     211     
    230212      using (Brush gridBrush = new SolidBrush(Color.LightGray)) {
    231213        Pen gridLinePen = new Pen(gridBrush);
     
    242224    }
    243225
     226    void dataGridView_KeyDown(object sender, KeyEventArgs e) {
     227      var selectedRows = dataGridView.SelectedRows;
     228      if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
     229        List<int> rows = new List<int>();
     230        for (int i = 0; i < selectedRows.Count; ++i) {
     231          rows.Add(selectedRows[i].Index);
     232        }
     233        triggersOwnEvent(() => {
     234          Content.DataGridLogic.DeleteRow(rows);
     235          OnContentChanged();
     236        });
     237      } else if (e.Control && e.KeyCode == Keys.F) {
     238        CreateFindAndReplaceDialog();
     239        findAndReplaceDialog.ActivateSearch();
     240      } else if (e.Control && e.KeyCode == Keys.R) {
     241        CreateFindAndReplaceDialog();
     242        findAndReplaceDialog.ActivateReplace();
     243      }
     244    }
     245
    244246    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
    245247      btnApplySort.Enabled = sortedColumns.Any();
Note: See TracChangeset for help on using the changeset viewer.