Click here to Skip to main content
15,881,715 members
Articles / Desktop Programming / Windows Forms

Autocomplete Menu

Rate me:
Please Sign up or sign in to vote.
4.89/5 (239 votes)
19 Mar 2015LGPL35 min read 825.2K   28.8K   390  
Customizable autocomplete menu for RichTextBox, TextBox and other controls
using System.Windows.Forms;
using AutocompleteMenuNS;

namespace Tester
{
    public partial class DataGridViewSample : Form
    {
        public DataGridViewSample()
        {
            InitializeComponent();

            for (int i = 0; i < 100; i++)
                dgv.Rows.Add();
        }

        private Control editControl;

        private void dgv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            autocompleteMenu1.TargetControlWrapper = null;
            autocompleteMenu1.SetAutocompleteMenu(editControl, null);
        }

        private void dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            editControl = e.Control;
            autocompleteMenu1.SetAutocompleteMenu(e.Control, autocompleteMenu1);
        }
    }

     /*
    internal class NoArrowNavigateDataGridView : DataGridView
    {
        public bool DisableArrowNavigationMode { get; set; }

        public NoArrowNavigateDataGridView()
        {
            DisableArrowNavigationMode = true;
        }

        protected override bool ProcessDialogKey(Keys keyData)
        {
            if (DisableArrowNavigationMode)
            if (EditingControl != null)
                if (keyData == Keys.Enter)
                    return false;
            return base.ProcessDialogKey(keyData);
        }

        protected override bool ProcessDataGridViewKey(KeyEventArgs e)
        {
            if (DisableArrowNavigationMode)
            if (EditingControl != null)
            if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up || e.KeyCode == Keys.Enter)
                return false;
            return base.ProcessDataGridViewKey(e);
        }
    }*/
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Software Developer Freelancer
Ukraine Ukraine
I am Pavеl Tоrgаshоv, and I live in Kyiv, Ukraine.
I've been developing software since 1998.
Main activities: processing of large volumes of data, statistics, computer vision and graphics.

Comments and Discussions