Example #1
0
            public void setDisabledColandRows(DataGridView dgv, DataTable dt)
            {
                //reset the column disabled properties
                foreach (DataColumn c in dt.Columns)
                {
                    bool hasattribute = c.ExtendedProperties.ContainsKey(VBTools.Globals.ENABLED);
                    if (hasattribute)
                    {
                        int selectedColIndex = dt.Columns.IndexOf(c);
                        //bool enabled = (bool)c.ExtendedProperties[VBTools.Globals.ENABLED];
                        //if (!enabled) //{ DisableCol(null, null); }
                        if (c.ExtendedProperties[VBTools.Globals.ENABLED].ToString() != "True")
                        {
                            for (int r = 0; r < dgv.Rows.Count; r++)
                            {
                                dgv[selectedColIndex, r].Style.ForeColor = Color.Red;
                            }
                        }
                    }
                }

                //reset disable rows
                _dtRI = dtRowInformation.getdtRI(dt, false);
                for (int r = 0; r < dt.Rows.Count; r++)
                {
                    bool enabled = _dtRI.getRowStatus(dt.Rows[r][0].ToString());
                    if (!enabled)
                    {
                        for (int c = 0; c < dgv.Columns.Count; c++)
                        {
                            dgv[c, r].Style.ForeColor = Color.Red;
                        }
                    }
                }
            }
Example #2
0
 /// <summary>
 /// constructor optionally calls method to init the row information structure
 /// and return the itself - singleton
 /// </summary>
 /// <param name="dt">table to gather info on</param>
 /// <param name="init">if true, initialize; for example, on import</param>
 /// <returns></returns>
 public static dtRowInformation getdtRI(DataTable dt, bool init)
 {
     //pass null after initialization to access the DTRowInfo property
     //or pass init=true (after import) to initialize
     if (dtRI == null || init)
     {
         dtRI = new dtRowInformation(dt);
     }
     return(dtRI);
 }
Example #3
0
            public void enableGridCol(DataGridView dgv, int selectedColIndex, DataTable dt)
            {
                dtRowInformation dtRI = dtRowInformation.getdtRI(dt, false);

                for (int r = 0; r < dgv.Rows.Count; r++)
                {
                    //set style to black unless the row is disabled
                    if (!dtRI.getRowStatus(dgv[0, r].Value.ToString()))
                    {
                        continue;
                    }
                    dgv[selectedColIndex, r].Style.ForeColor = Color.Black;
                }
            }
Example #4
0
        /// <summary>
        /// Constructor takes the datagridview to show changes implemented in this class
        /// </summary>
        /// <param name="dgv">datasheet grid reference</param>
        /// <param name="dt">datasource for the grid</param>
        public frmMissingValues(DataGridView dgv, DataTable dt)
        {
            InitializeComponent();

            _tu   = new Utilities.TableUtils(dt);
            _dtRI = dtRowInformation.getdtRI(_dt, false);
            _dtCI = dtColumnInformation.getdtCI(dt, false);

            //get a working copy of the dataset
            _dt  = dt.Copy();
            _dgv = dgv;

            cboCols.DataSource = _ddlReplaceWith;

            btnReturn.Enabled = false;

            //this.TopMost = true;
        }
Example #5
0
 public TableUtils(DataTable dt)
 {
     _dt   = dt;
     _dtCI = dtColumnInformation.getdtCI(dt, false);
     _dtRI = dtRowInformation.getdtRI(dt, false);
 }
Example #6
0
            public void maintainGrid(DataGridView dgv, DataTable dt, int selectedColIndex, string responseVarColName)
            {
                //reset the grid
                dgv.DataSource = null;
                dgv.DataSource = dt;

                //mark all grid cols visible, not sortable
                for (int c = 0; c < dgv.Columns.Count; c++)
                {
                    //dgv.Columns[c].Visible = true;
                    dgv.Columns[c].SortMode = DataGridViewColumnSortMode.NotSortable;
                }

                //hide any main effect cols that have been transformed (hidden attribute is set in the transform class)
                foreach (DataColumn c in dt.Columns)
                {
                    bool hashidden = c.ExtendedProperties.ContainsKey(VBTools.Globals.HIDDEN);
                    if (hashidden == true)
                    {
                        //bool hide = c.ExtendedProperties[VBTools.Globals.HIDDEN].Equals(true);
                        //bool hide = (bool)c.ExtendedProperties[VBTools.Globals.HIDDEN];
                        //if (hide)
                        if (c.ExtendedProperties[VBTools.Globals.HIDDEN].ToString() == "True")
                        {
                            dgv.Columns[c.ColumnName].Visible = false;
                        }
                    }
                    //reset the column disabled properties
                    bool hasattribute = c.ExtendedProperties.ContainsKey(VBTools.Globals.ENABLED);
                    if (hasattribute)
                    {
                        selectedColIndex = dt.Columns.IndexOf(c);
                        //this is not working after serialization....
                        //bool enabled = (bool)c.ExtendedProperties[VBTools.Globals.ENABLED];
                        if (c.ExtendedProperties[VBTools.Globals.ENABLED].ToString() != "True")
                        //if (!enabled)
                        {
                            for (int r = 0; r < dgv.Rows.Count; r++)
                            {
                                dgv[selectedColIndex, r].Style.ForeColor = Color.Red;
                            }
                        }
                        else
                        {
                            for (int r = 0; r < dgv.Rows.Count; r++)
                            {
                                dgv[selectedColIndex, r].Style.ForeColor = Color.Black;
                            }
                        }
                    }
                }

                //reset the UI clues for the response variable
                dgv.Columns[responseVarColName].DefaultCellStyle.BackColor = Color.LightBlue;

                //reset disable rows
                _dtRI = dtRowInformation.getdtRI(dt, false);
                for (int r = 0; r < dt.Rows.Count; r++)
                {
                    bool enabled = _dtRI.getRowStatus(dt.Rows[r][0].ToString());
                    if (!enabled)
                    {
                        for (int c = 0; c < dgv.Columns.Count; c++)
                        {
                            dgv[c, r].Style.ForeColor = Color.Red;
                        }
                    }
                }

                ////hide any main effect cols that have been transformed (hidden attribute is set in the transform class)
                //foreach (DataColumn c in dt.Columns)
                //{

                //    bool hasattribute = c.ExtendedProperties.ContainsKey(VBTools.Globals.HIDDEN);
                //    if (hasattribute == true)
                //    {
                //        bool hide = (bool)c.ExtendedProperties[VBTools.Globals.HIDDEN];
                //        if (hide) { dgv.Columns[c.ColumnName].Visible = false; }
                //    }
                //    //reset the column disabled properties
                //    hasattribute = c.ExtendedProperties.ContainsKey(VBTools.Globals.ENABLED);
                //    if (hasattribute)
                //    {
                //        selectedColIndex = dt.Columns.IndexOf(c);
                //        bool enabled = (bool)c.ExtendedProperties[VBTools.Globals.ENABLED];
                //        if (!enabled) //{ DisableCol(null, null); }
                //        {
                //            for (int r = 0; r < dgv.Rows.Count; r++)
                //                dgv[selectedColIndex, r].Style.ForeColor = Color.Red;
                //        }
                //    }

                //}

                //set the numerical precision for display
                setViewOnGrid(dgv);
            }