//Set column header names in Variable Selection listbox public void UpdateData(object source, EventArgs e) { dt = dsControl1.DT; this.correlationData = dsControl1.DT; _dtFull = dt; if (_dtFull == null) return; tabControl1.SelectedIndex = 0; List<string> lstFieldList = new List<string>(); for (int i = 2; i < _dtFull.Columns.Count; i++) { if (_dtFull.Columns[i].ExtendedProperties.ContainsKey(VBCommon.Globals.ENABLED)) { if (_dtFull.Columns[i].ExtendedProperties[VBCommon.Globals.ENABLED].ToString() == "True") lstFieldList.Add(_dtFull.Columns[i].ColumnName); } else lstFieldList.Add(_dtFull.Columns[i].ColumnName); } intNumObs = _dtFull.Rows.Count; lblNumObs.Text = "Number of Observations: " + intNumObs.ToString(); lbAvailableVariables.Items.Clear(); lbIndVariables.Items.Clear(); for (int i = 0; i < lstFieldList.Count; i++) { ListItem li = new ListItem(lstFieldList[i], i.ToString()); lbAvailableVariables.Items.Add(li); } lblAvailVars.Text = "(" + lbAvailableVariables.Items.Count.ToString() + ")"; lblDepVars.Text = "(" + lbIndVariables.Items.Count.ToString() + ")"; lbDepVarName.Text = _dtFull.Columns[1].ColumnName.ToString(); }
/// <summary> /// Loads the lists with datatable variable names (column headers) /// </summary> /// <param name="dt"></param> private void SetData(DataTable dt) { //populate the list boxes with column names //default col 1 is dependent variable, all later cols are independent _dtFull = dt; if (_dtFull == null) return; List<string> fieldList = new List<string>(); //skip date/time column for (int i = 1; i < _dtFull.Columns.Count; i++) fieldList.Add(_dtFull.Columns[i].ColumnName); lbIndVariables.Items.Clear(); //add items to independent variable listbox...but move them to ignored (alpha data) or //categorical (number of distinct values <= 2) listboxes for (int i = 1; i < fieldList.Count; i++) { ListItem li = new ListItem(fieldList[i], i.ToString()); lbIndVariables.Items.Add(li); //if categorical, move it to categorical box bool hascat = _dtFull.Columns[li.ToString()].ExtendedProperties.ContainsKey(VBCommon.Globals.CATEGORICAL); var distinctVals = (from row in _dtFull.Select() select row[li.ToString()]).Distinct(); if (distinctVals.Count() <= 2 && Information.IsNumeric(distinctVals.First().ToString())) { _dtFull.Columns[li.ToString()].ExtendedProperties[VBCommon.Globals.CATEGORICAL] = true; object btn = button3; int ndx = lbIndVariables.FindString(li.ToString()); lbIndVariables.SelectedItem = lbIndVariables.Items[ndx]; btnRemoveInputVariable_Click_1(btn, new EventArgs()); } //if its already been identified, add it to the list else if (hascat) { if (hascat == true) { bool iscat = (bool)_dtFull.Columns[li.ToString()].ExtendedProperties[VBCommon.Globals.CATEGORICAL]; if (iscat) { object btn = button3; int ndx = lbIndVariables.FindString(li.ToString()); lbIndVariables.SelectedItem = lbIndVariables.Items[ndx]; btnRemoveInputVariable_Click_1(btn, new EventArgs()); } } } } }
/*//Set column header names in Variable Selection listbox public void SetData(IDictionary<string,object> packedState) { //Datasheet's packed state coming in dictPackedPlugin = packedState; dt = (DataTable)dictPackedPlugin["DT"]; this.correlationData = (DataTable)dictPackedPlugin["CorrelationDataTable"]; //init in case they've re-imported dsControl1.dgv.DataSource = null; //set the dgv dsControl1.dgv.DataSource = correlationData; dsControl1.DT = (DataTable)dictPackedPlugin["DT"]; dsControl1.SelectedColIndex = (int)dictPackedPlugin["CurrentColIndex"]; dsControl1.ResponseVarColName = (string)dictPackedPlugin["DepVarColName"]; //dsControl1.DTCI.DTColInfo = (Dictionary<string, bool>)dictPackedPlugin["DTColInfo"]; //dsControl1.DTRI.DTRowInfo = (Dictionary<string, bool>)dictPackedPlugin["DTRowInfo"]; dsControl1.DisabledRows = (int)dictPackedPlugin["DisabledRwCt"]; dsControl1.DisabledCols = (int)dictPackedPlugin["DisabledColCt"]; dsControl1.HiddenCols = (int)dictPackedPlugin["HiddenColCt"]; dsControl1.NumberIVs = (int)dictPackedPlugin["IndVarCt"]; dsControl1.FileName = (string)dictPackedPlugin["fileName"]; dsControl1.showListInfo(fn, dt); _dtFull = dt; if (_dtFull == null) return; tabControl1.SelectedIndex = 0; List<string> lstFieldList = new List<string>(); for (int i = 2; i < _dtFull.Columns.Count; i++) { if (_dtFull.Columns[i].ExtendedProperties.ContainsKey(VBCommon.Globals.ENABLED)) { if (_dtFull.Columns[i].ExtendedProperties[VBCommon.Globals.ENABLED].ToString() == "True") lstFieldList.Add(_dtFull.Columns[i].ColumnName); } else lstFieldList.Add(_dtFull.Columns[i].ColumnName); } intNumObs = _dtFull.Rows.Count; lblNumObs.Text = "Number of Observations: " + intNumObs.ToString(); lbAvailableVariables.Items.Clear(); lbIndVariables.Items.Clear(); for (int i = 0; i < lstFieldList.Count; i++) { ListItem li = new ListItem(lstFieldList[i], i.ToString()); lbAvailableVariables.Items.Add(li); } lblAvailVars.Text = "(" + lbAvailableVariables.Items.Count.ToString() + ")"; lblDepVars.Text = "(" + lbIndVariables.Items.Count.ToString() + ")"; lbDepVarName.Text = _dtFull.Columns[1].ColumnName.ToString(); } */ //Set column header names in Variable Selection listbox public void SetData(IDictionary<string, object> packedState) { //Datasheet's packed state coming in dictPackedPlugin = packedState; dsControl1.UnpackState((IDictionary<string, object>)dictPackedPlugin["PackedDatasheetState"]); dt = dsControl1.DT; this.correlationData = dsControl1.DT; _dtFull = dt; if (_dtFull == null) return; tabControl1.SelectedIndex = 0; List<string> lstFieldList = new List<string>(); for (int i = 2; i < _dtFull.Columns.Count; i++) { if (_dtFull.Columns[i].ExtendedProperties.ContainsKey(VBCommon.Globals.ENABLED)) { if (_dtFull.Columns[i].ExtendedProperties[VBCommon.Globals.ENABLED].ToString() == "True") lstFieldList.Add(_dtFull.Columns[i].ColumnName); } else lstFieldList.Add(_dtFull.Columns[i].ColumnName); } intNumObs = _dtFull.Rows.Count; lblNumObs.Text = "Number of Observations: " + intNumObs.ToString(); lbAvailableVariables.Items.Clear(); lbIndVariables.Items.Clear(); for (int i = 0; i < lstFieldList.Count; i++) { ListItem li = new ListItem(lstFieldList[i], i.ToString()); lbAvailableVariables.Items.Add(li); } lblAvailVars.Text = "(" + lbAvailableVariables.Items.Count.ToString() + ")"; lblDepVars.Text = "(" + lbIndVariables.Items.Count.ToString() + ")"; lbDepVarName.Text = _dtFull.Columns[1].ColumnName.ToString(); }