Пример #1
0
 protected override void ProcessFindItem(KeyPressHelper helper, char pressedKey)
 {
     filterText = helper.Text;
     if (filterText == "" || filterText == null)
     {
         Properties.TreeList.FocusedNode = Properties.PrevFocusedNode;
     }
     base.ProcessFindItem(helper, pressedKey);
     if (filterText != "" && Properties.SearchMode != SearchMode.OnlyInPopup)
     {
         TreeListNode node = Properties.GetNodeByDisplayText(Properties.TreeList.Nodes, filterText, Properties.DisplayMember);
         if (node != null)
         {
             string nodeText = node.GetDisplayText(Properties.DisplayMember);
             EditValue            = node[Properties.ValueMember];
             AutoSearchText       = filterText;
             this.SelectionStart  = helper.GetCorrectedAutoSearchSelectionStart(Text, pressedKey);
             this.SelectionLength = nodeText.Length - this.SelectionStart;
             if (Properties.TreeList.FocusedNode != null)
             {
                 if (Properties.TreeList.FocusedNode != Properties.PrevFocusedNode)
                 {
                     Properties.PrevFocusedNode = Properties.TreeList.FocusedNode;
                 }
             }
             Properties.TreeList.FocusedNode = node;
             LayoutChanged();
         }
     }
 }
Пример #2
0
        protected override void ProcessFindItem(KeyPressHelper helper, char pressedKey)
        {
            if (Properties.ReadOnly)
            {
                return;
            }
            int    selectionStart = helper.SelectionStart;
            string searchText     = AutoSearchText;
            int    itemIndex      = FindItem(searchText, 0);
            bool   isOpened       = IsPopupOpen;

            if (IsImmediatePopup)
            {
                DoImmediatePopup(itemIndex, pressedKey);
                if (!isOpened && IsPopupOpen)
                {
                    itemIndex = FindItem(searchText, 0);
                }
            }
            if (IsPopupOpen)
            {
                FindUpdatePopupSelectedItem(itemIndex);
            }
            if (itemIndex != -1)
            {
                FindUpdateEditValue(itemIndex, false);
                if (IsMaskBoxAvailable)
                {
                    UpdateMaskBoxDisplayText();
                    selectionStart  = helper.GetCorrectedAutoSearchSelectionStart(Text, pressedKey);
                    SelectionStart  = selectionStart;
                    SelectionLength = Text.Length - selectionStart;
                }
            }
            else
            {
                if (IsMaskBoxAvailable)
                {
                    FindUpdateEditValueAutoSearchText();
                    UpdateMaskBoxDisplayText();
                    SelectionStart  = Math.Max(0, selectionStart);
                    SelectionLength = 0;
                }
                else
                {
                    AutoSearchText = AutoSearchText.Length > 1 ? AutoSearchText.Substring(0, AutoSearchText.Length - 1) : string.Empty;
                }
            }
            LayoutChanged();
        }