private void FillGrid(bool refreshList = true, bool isScrollToSelection = true)
        {
            if (refreshList)
            {
                _listQueries = UserQueries.GetDeepCopy();
            }
            string[] strSearchTerms = Regex.Split(textSearch.Text, @"\W");           //matches any non-word character
            //get all queries that contain ALL of the search terms entered, either in the query text or the query description.
            List <UserQuery> listDisplayQueries = _listQueries
                                                  .Where(x => strSearchTerms.All(y =>
                                                                                 x.QueryText.ToLowerInvariant().Contains(y.ToLowerInvariant()) || x.Description.ToLowerInvariant().Contains(y.ToLowerInvariant())
                                                                                 )).ToList();
            //attempt to preserve the currently selected query.
            long selectedQueryNum = 0;

            if (gridMain.GetSelectedIndex() != -1)
            {
                selectedQueryNum = gridMain.SelectedTag <UserQuery>().QueryNum;
            }
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "Query"), 350));
            if (Security.IsAuthorized(Permissions.UserQueryAdmin, true))
            {
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "Released"), 55, HorizontalAlignment.Center));
            }
            gridMain.ListGridRows.Clear();
            foreach (UserQuery queryCur in listDisplayQueries)
            {
                if (!Security.IsAuthorized(Permissions.UserQueryAdmin, true) && !queryCur.IsReleased)
                {
                    continue;                     //non-released queries only appear for people with UserQueryAdmin permission.
                }
                GridRow row = new GridRow();
                row.Cells.Add(queryCur.Description);
                if (Security.IsAuthorized(Permissions.UserQueryAdmin, true))
                {
                    row.Cells.Add(queryCur.IsReleased ? "X" : "");
                }
                row.Tag = queryCur;
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            int selectedIdx = gridMain.ListGridRows.Select(x => (UserQuery)x.Tag).ToList().FindIndex(y => y.QueryNum == selectedQueryNum);

            if (selectedIdx > -1)
            {
                gridMain.SetSelected(selectedIdx, true);
            }
            if (gridMain.GetSelectedIndex() == -1)
            {
                gridMain.SetSelected(0, true);                //can handle values outside of the row count (so if there are no rows, this will not fail)
            }
            if (isScrollToSelection)
            {
                gridMain.ScrollToIndex(gridMain.GetSelectedIndex());                 //can handle values outside of the row count
            }
            RefreshQueryCur();
        }