/// <summary> /// Constructor. /// </summary> /// <param name="data">The model to show all entrys of</param> public ShowParsedFileContent(DatabaseDataSet data) { // set bindinglist for gridview this.data = data; DataTable dt = new DataTable(); if (!data.isFiltered) { dt.Load(data.getData()); } InitializeComponent(); #region Custom Init // Display filename in title this.Text += " " + data.FileName; // prepare for custom data-source and columns this.fileContentDataGrid.AutoGenerateColumns = false; if (data.isFiltered) { this.fileContentDataGrid.DataSource = data.getData(); } else { this.fileContentDataGrid.DataSource = dt; } // add columns supported by data foreach (SensorData t in Enum.GetValues(typeof(SensorData))) { FieldInfo fi = t.GetType().GetField(t.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); if(data.SupportedValues.Contains(t)) { DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.DataPropertyName = t.ToString(); col.HeaderText = attributes[0].Description; this.fileContentDataGrid.Columns.Add(col); } } #endregion }