Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Data.Views/3.3/ColumnsVisibilityDialog.cs @ 3316

Last change on this file since 3316 was 3316, checked in by mkommend, 12 years ago

added possibility to change visibility of columns in StringConvertibleMatrixView (ticket #968)

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9
10namespace HeuristicLab.Data.Views {
11  public partial class ColumnsVisibilityDialog : Form {
12    public ColumnsVisibilityDialog() {
13      InitializeComponent();
14    }
15
16    public ColumnsVisibilityDialog(IEnumerable<DataGridViewColumn> columns) :this() {
17      this.Columns = columns;
18    }
19
20    private List<DataGridViewColumn> columns;
21    public IEnumerable<DataGridViewColumn> Columns {
22      get { return this.columns; }
23      set {
24        this.columns = new List<DataGridViewColumn>(value);
25        UpdateCheckBoxes();
26      }
27    }
28
29    private void UpdateCheckBoxes() {
30      this.checkedListBox.Items.Clear();
31      foreach (DataGridViewColumn column in columns)
32        checkedListBox.Items.Add(column.HeaderText, column.Visible);
33    }
34
35    private void checkedListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
36      this.columns[e.Index].Visible = e.NewValue == CheckState.Checked;
37    }
38  }
39}
Note: See TracBrowser for help on using the repository browser.