public static void SetRowsVisibilityByScore(DataGridView gridView, double threshold, bool visState)
 {
     Console.WriteLine("Hiding");
     gridView.SuspendLayout();
     CurrencyManager currencyManager = gridView.BindingContext[gridView.DataSource] as CurrencyManager;
     currencyManager.SuspendBinding();
     int timeElapsed = Environment.TickCount;
     foreach(DataGridViewRow row in gridView.Rows)
     {
         int timeTick = Environment.TickCount;
         Console.WriteLine("Toggling row {0} - {1}", row, timeTick - timeElapsed);
         timeElapsed = timeTick;
         try
         {
             double ms2Score = (double)row.Cells.GetCellValueFromColumnHeader("MS2 Score");
             if (ms2Score < threshold)
             {
                 row.Visible = visState;
             }
         }
         catch
         {
             Console.WriteLine(row);
             //row.Visible = false;
         }
     }
     currencyManager.ResumeBinding();
     gridView.ResumeLayout();
     gridView.Refresh();
 }
Example #2
0
        private void fill(DataGridView grid, string filter = null)
        {
            if(!String.IsNullOrWhiteSpace(filter)) {
                filter = filter.ToLower();
            }

            grid.SuspendLayout();
            grid.Rows.Clear();
            foreach(EnvDTE.Command cmd in _commands)
            {
                if(String.IsNullOrWhiteSpace(cmd.Name) || (filter != null && !cmd.Name.ToLower().Contains(filter))) {
                    continue;
                }
                grid.Rows.Add(cmd.Name);
            }
            grid.ResumeLayout();
            labelPropCount.Text = grid.Rows.Count.ToString();
        }
Example #3
0
 private static void UpDownOrDelete(bool? isUp, DataGridView dataGridView1)
 {
     Clips.BoardDataTable clips = null;
     if (dataGridView1 == null
             || dataGridView1.SelectedCells == null
             || dataGridView1.SelectedCells.Count < 1
             || (clips = dataGridView1.DataSource as Clips.BoardDataTable) == null)
         return;
     dataGridView1.SuspendLayout();
     Dictionary<int, int> idxs = new Dictionary<int, int>();
     for (int i = 0; i < dataGridView1.SelectedCells.Count; i++)
         idxs.Add(dataGridView1.SelectedCells[i].RowIndex, -1);
     List<int> rows = new List<int>();
     foreach (int id in idxs.Keys)
         rows.Add(id);
     for (int i = rows.Count - 1; i >= 0; i--)
         if (rows[i] < 0
                 || rows[i] >= dataGridView1.RowCount)
             return;
     rows.Sort();
     if (isUp == null)
     {
         for (int i = rows.Count - 1; i >= 0; i--)
             clips.Rows.RemoveAt(rows[i]);
     }
     else
     {
         int diff = rows[rows.Count - 1] - rows[0];
         int plus = 1;
         int temp = 0;
         for (int i = 1; i < rows.Count; i++)
         {
             if (Math.Abs(rows[i - 1] - rows[i]) == 1)
             {
                 temp++;
                 if (i != rows.Count - 1)
                     continue;
             }
             if (plus < temp)
                 plus = temp;
             temp = 0;
         }
         diff += plus;
         for (int i = 0; i < rows.Count; i++)
             idxs[rows[i]] = rows[i] + (isUp == true ? -diff : diff);
         for (int i = 0; i < rows.Count; i++)
             if (idxs[rows[i]] < 0
                     || idxs[rows[i]] >= dataGridView1.RowCount)
                 return;
         List<Clips.BoardRow> boards = new List<Clips.BoardRow>();
         for (int i = rows.Count - 1; i >= 0; i--)
         {
             Clips.BoardRow board = clips.NewBoardRow();
             board.ItemArray = clips[rows[i]].ItemArray;
             boards.Add(board);
             clips.Rows.RemoveAt(rows[i]);
         }
         for (int i = 0; i < boards.Count; i++)
             clips.Rows.InsertAt(boards[boards.Count - i - 1], idxs[rows[i]]);
         for (int i = 0; i < dataGridView1.SelectedCells.Count; i++)
             dataGridView1.SelectedCells[i--].Selected = false;
         for (int i = 0; i < rows.Count; i++)
             dataGridView1[(int)GridColumns.BoardText, idxs[rows[i]]].Selected = true;
     }
     dataGridView1.Invalidate();
     dataGridView1.ResumeLayout();
 }
Example #4
0
 private void SetAllCheckboxes(DataGridView dgv, int checkboxColumnIndex, bool isChecked)
 {
     dgv.Enabled = false;
     dgv.SuspendLayout();
     dgv.Rows.Cast<DataGridViewRow>().ToList().ForEach(row =>
     {
         row.Cells[checkboxColumnIndex].Value = isChecked;
     });
     dgv.ResumeLayout();
     RenderArticleCount();
     dgv.Enabled = true;
 }
        public static void FilterGridView(DataGridView vw, string searchstr)
        {
            vw.SuspendLayout();

            DataGridViewRow[] theRows = new DataGridViewRow[vw.Rows.Count];
            vw.Rows.CopyTo(theRows, 0);
            vw.Rows.Clear();

            for (int loop = 0; loop < theRows.Length; loop++)
            {
                bool found = false;

                if (searchstr.Length < 1)
                    found = true;
                else
                {
                    foreach (DataGridViewCell cell in theRows[loop].Cells)
                    {
                        if (cell.Value != null)
                        {
                            if (cell.Value.ToString().IndexOf(searchstr, 0, StringComparison.CurrentCultureIgnoreCase) >= 0)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                }

                theRows[loop].Visible = found;
            }

            vw.Rows.AddRange(theRows);
            vw.ResumeLayout();
        }
Example #6
0
        /// <summary>
        /// Duylnk added: DataGridView
        /// </summary>
        /// <param name="grd"></param>
        public static void SetStyle(DataGridView grd)
        {
            grd.SuspendLayout();
            if (ThemeColor == Style.Blue)
            {
                grd.BackgroundColor = Color.FromArgb(227, 242, 252);
                grd.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(217, 232, 252);//Color.FromArgb(229, 255, 255);//Color.Blue;//Color.MidnightBlue;
                grd.ColumnHeadersDefaultCellStyle.ForeColor = Color.MidnightBlue;
                grd.RowHeadersDefaultCellStyle.BackColor = Color.FromArgb(217, 232, 252);

                grd.DefaultCellStyle.BackColor = Color.FromArgb(227, 242, 252);
                grd.DefaultCellStyle.SelectionBackColor = SystemColors.ActiveCaption;
                grd.DefaultCellStyle.SelectionForeColor = SystemColors.ActiveCaptionText;

                foreach (DataGridViewColumn grdCol in grd.Columns)
                {
                    if (!grdCol.ReadOnly)
                    {
                        grdCol.DefaultCellStyle.BackColor = Color.FromArgb(255, 224, 192);
                        grdCol.DefaultCellStyle.SelectionBackColor = SystemColors.ActiveCaption;
                        grdCol.DefaultCellStyle.SelectionForeColor = SystemColors.ActiveCaptionText;
                    }
                }
            }

            grd.ResumeLayout();
        }