/// <summary> /// adds the controls to select the displayed values for the string columns /// </summary> /// <param name="columnNames"></param> public void setupStringSelect(string[] columnNames) { for (int columnNum = 0; columnNum < columnNames.Length; columnNum++) { string colName = columnNames[columnNum]; string[] values = getDistinctValsInCol(colName); FlowLayoutPanel flpSelection = new FlowLayoutPanel() { Name = "flpSelection" + columnNum }; flpSelection.Controls.Add(new Label() { Name = "colLabel", Text = colName }); SqlSelectProperty sqlSelect = new SqlSelectProperty() { columnName = colName }; CheckBox chkDisplay = new CheckBox() { Name = "chkDisplay", Text = "Display", Checked = true }; chkDisplay.DataBindings.Add("Checked", sqlSelect, "IsEnabled"); flpSelection.Controls.Add(chkDisplay); if (values.Length < kMaxValsToSelect) { ListBox lstSelections = new ListBox() { Name = "lstSelections" }; lstSelections.DataSource = values; lstSelections.SelectionMode = SelectionMode.MultiExtended; SqlStringWhereProperty sqlStringWhere = new SqlStringWhereProperty(lstSelections, colName); CheckBox chkEnabled = new CheckBox() { Name = "chkEnabled", Text = "Apply filter" }; chkEnabled.DataBindings.Add("Checked", sqlStringWhere, "IsEnabled"); flpSelection.Controls.Add(chkEnabled); flpSelection.Controls.Add(lstSelections); sqlWhereProperties.Add(sqlStringWhere); } sqlSelectProperties.Add(sqlSelect); flpSelection.AutoSize = true; flpSelection.FlowDirection = FlowDirection.TopDown; flpStringSelect.Controls.Add(flpSelection); } //It's best not to turn on auto scroll until all the elements are added or it will try to calculate the scroll for each one flpStringSelect.AutoScroll = true; }
/// <summary> /// adds the controls to select the range of the number columns to the form with the appropriate binding /// </summary> /// <param name="columnNames"> The names of all of the columns </param> /// <param name="numColNames"> The names of the num columns (the rest are the date)</param> public void setupRangeSelect(string[] columnNames, string[] numColNames) { for (int entryNum = 0; entryNum < columnNames.Length; entryNum++) { SqlProperty sqlWhere; SqlSelectProperty sqlSelect = new SqlSelectProperty(); TextBoxBase txtLower; TextBoxBase txtUpper; const string kDateMaskString = "00/00/0000"; if (numColNames.Contains(columnNames[entryNum])) {//Num sqlWhere = new SqlNumWhereProperty(); txtLower = new TextBox(); txtUpper = new TextBox(); } else {//Date sqlWhere = new SqlDateWhereProperty(); txtLower = new MaskedTextBox(); txtUpper = new MaskedTextBox(); ((MaskedTextBox)txtLower).Mask = kDateMaskString; ((MaskedTextBox)txtUpper).Mask = kDateMaskString; } txtLower.Name = "txtLower" + entryNum; txtUpper.Name = "txtUpper" + entryNum; sqlWhere.columnName = columnNames[entryNum]; sqlSelect.columnName = columnNames[entryNum]; txtLower.DataBindings.Add("Text", sqlWhere, "LowerLimit"); txtUpper.DataBindings.Add("Text", sqlWhere, "UpperLimit"); CheckBox chkDisplay = new CheckBox() { Name = "chkDisplay" + entryNum, Text = "Display", Checked = true }; chkDisplay.DataBindings.Add("Checked", sqlSelect, "IsEnabled"); CheckBox chkEnabled = new CheckBox() { Name = "chkEnabled" + entryNum, Text = "Enabled" }; chkEnabled.DataBindings.Add("Checked", sqlWhere, "IsEnabled"); sqlWhereProperties.Add(sqlWhere); sqlSelectProperties.Add(sqlSelect); tblWhereSelection.RowCount++; tblWhereSelection.Controls.Add(new Label() { Text = columnNames[entryNum] }, 0, entryNum); tblWhereSelection.Controls.Add(chkDisplay, 1, entryNum); tblWhereSelection.Controls.Add(chkEnabled, 2, entryNum); tblWhereSelection.Controls.Add(txtLower, 3, entryNum); tblWhereSelection.Controls.Add(new Label() { Text = "<= " + sqlWhere.columnName + " <=" }, 4, entryNum); tblWhereSelection.Controls.Add(txtUpper, 5, entryNum); } tblWhereSelection.AutoScroll = true; }