Esempio n. 1
0
        // core method

        private void AutoComplete()
        {
            // get editor
            TextBox tb = _flex.Editor as TextBox;

            if (tb == null)
            {
                return;
            }

            // get current editor content
            string strEdit = tb.Text;
            int    len     = strEdit.Length;

            // autocomplete only at the end of the text
            if (tb.SelectionStart < len)
            {
                return;
            }

            // look for match on the same column
            int row = _flex.FindRow(strEdit, _flex.Rows.Fixed, _flex.Col, false, false, false);

            // if a match was found, handle it
            if (row > -1 && row != _flex.Row)
            {
                // get matching text
                string match = _flex.GetDataDisplay(row, _flex.Col);

                // put matching text in editor
                if (tb.Text != match)
                {
                    tb.Text = match;
                }

                // select part that was guessed (not typed)
                tb.Select(len, match.Length - len);
            }
        }