Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/TableResultsView.cs @ 1106

Last change on this file since 1106 was 1106, checked in by gkronber, 15 years ago

worked on presentation layer for CEDMA. Added a results view that displays data in a simple DataGrid. (#419)

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Core;
10using HeuristicLab.CEDMA.Core;
11
12namespace HeuristicLab.CEDMA.Core {
13  public partial class TableResultsView : ViewBase, IResultsView {
14    private Results results;
15    public TableResultsView() {
16      InitializeComponent();
17    }
18
19    public Control Control {
20      get { return this; }
21    }
22
23    public void ShowResults(Results results) {
24      this.results = results;
25      UpdateControls();
26    }
27
28    protected override void UpdateControls() {
29      base.UpdateControls();
30      if (results == null) return;
31      List<string> columnNames = new List<string>();
32      columnNames.AddRange(Results.CategoricalVariables);
33      columnNames.AddRange(Results.OrdinalVariables);
34      dataGridView.Rows.Clear();
35      dataGridView.Columns.Clear();
36      foreach (string varName in columnNames) {
37        dataGridView.Columns.Add(varName, varName);
38      }
39
40      foreach (object[] row in results.SelectRows(columnNames)) {
41        dataGridView.Rows.Add(row);
42      }
43      dataGridView.Update();
44    }
45  }
46}
Note: See TracBrowser for help on using the repository browser.