Example #1
0
        private void _searchBox_Search(object sender, EventArgs e)
        {
            // configure filter
            _searchFilter.Condition1.Operator  = ConditionOperator.Contains;
            _searchFilter.Condition1.Parameter = _searchBox.Text;

            // apply filter
            var count = 0;

            _flexSearch.BeginUpdate();
            for (int r = _flexSearch.Rows.Fixed; r < _flexSearch.Rows.Count; r++)
            {
                bool visible = false;
                for (int c = _flexSearch.Cols.Fixed; c < _flexSearch.Cols.Count; c++)
                {
                    if (_searchFilter.Apply(_flexSearch[r, c]))
                    {
                        visible = true;
                        count++;
                        break;
                    }
                }
                _flexSearch.Rows[r].Visible = visible;
            }
            _flexSearch.EndUpdate();

            _lblSearchCount.Text = string.Format("{0:n0} items", count);
        }
Example #2
0
        /// <summary>
        /// フィルタ設定
        /// </summary>
        /// <param name="cur"></param>
        /// <param name="grid"></param>
        /// <param name="condition"></param>
        /// <param name="msg"></param>
        //HACK 引数msgは使用していない。
        public void SetGridFilter(Cursor cur, C1FlexGrid grid, string condition, string msg)
        {
            // フィルタを構成します。
            _searchFilter.Condition1.Operator  = ConditionOperator.Contains;
            _searchFilter.Condition1.Parameter = condition;

            int count = 0;

            try {
                // フィルタを設定します。
                grid.BeginUpdate();
                for (int r = grid.Rows.Fixed; r < grid.Rows.Count; r++)
                {
                    bool visible = false;
                    for (int c = grid.Cols.Fixed; c < grid.Cols.Count; c++)
                    {
                        Column col = grid.Cols[c];
                        Object val = null;
                        //表示列のみフィルタ対象とする。
                        if (col.Visible == true)
                        {
                            if (col.DataMap != null)
                            {
                                //プルダウンの場合、名称でフィルタリング
                                Dictionary <string, string> dic = (Dictionary <string, string>)col.DataMap;
                                if (dic.ContainsKey(StringUtil.NullToBlank(grid[r, c])))
                                {
                                    val = dic[grid[r, c].ToString()].ToString();
                                }
                            }
                            else
                            {
                                val = grid[r, c];
                            }
                        }
                        if (_searchFilter.Apply(val))
                        {
                            visible = true;
                            count++;
                            break;
                        }
                    }
                    grid.Rows[r].Visible = visible;
                    Application.DoEvents();
                }
            } finally {
                grid.EndUpdate();
            }
        }