예제 #1
0
        void dsbExternal_PerformSearch(object sender, PerformSearchEventArgs e)
        {
            string adoFilter = String.Format("Word LIKE '{0}%'", e.SearchTerm.Replace("'", "''"));

            foreach (DataRow dr in _table.Select(adoFilter))
            {
                e.CancellationToken.ThrowIfCancellationRequested();
                e.Results.Add(new ComboTreeNode(dr.Field <string>(0)));
            }
        }
    protected virtual void OnPerformSearch(PerformSearchEventArgs e)
    {
        if (PerformSearch != null)
        {
            PerformSearch(this, e);
        }

        if (!e.Handled)
        {
            // default search logic
            foreach (ComboTreeNode node in AllNormalNodes)
            {
                e.CancellationToken.ThrowIfCancellationRequested();

                if (DefaultSearchPredicate(node, e.SearchTerm))
                {
                    e.Results.Add(node.Clone());
                }
            }
        }
    }
예제 #3
0
        void dsbListItems_PerformSearch(object sender, PerformSearchEventArgs e)
        {
            if (chkRetainGroups.Checked)
            {
                foreach (ComboTreeNode node in dsbListItems.AllNormalNodes)
                {
                    e.CancellationToken.ThrowIfCancellationRequested();

                    if (dsbListItems.DefaultSearchPredicate(node, e.SearchTerm))
                    {
                        // get all ancestor nodes (including the result)
                        Stack <ComboTreeNode> ancestors = new Stack <ComboTreeNode>();
                        ComboTreeNode         current   = node;
                        while (current != null)
                        {
                            ancestors.Push(current);
                            current = current.Parent;
                        }

                        // copy ancestor nodes into search results (or re-use existing)
                        ComboTreeNodeCollection collection = e.Results;
                        while (ancestors.Any())
                        {
                            current = ancestors.Pop();

                            ComboTreeNode copy = e.Results.Find(x => dsbListItems.DefaultEquivalencePredicate(x, current), true);
                            if (copy == null)
                            {
                                collection.Add(copy = current.Clone());
                            }

                            collection = copy.Nodes;
                        }
                    }
                }

                e.Handled = true;
            }
        }