// the constructor
        public AutoCompleteTextbox_Thuoc()
            : base()
        {
            // assigning some default values
            // minimum characters to be typed before suggestions are displayed
            this.MinTypedCharacters = 2;
            ExtraWidth = 0;
            ExtraWidth_Pre = 0;
            GridView = true;
            RaiseEventEnter = false;
            RaiseEventEnterWhenEmpty = false;
            DefaultCode = "-1";
            DefaultID = "-1";
            splitChar = '@';
            splitCharIDAndCode = '#';
            MaxHeight = -1;
            RaiseEvent = false;
            CompareNoID = true;
            FillValueAfterSelect = false;
            MyID = DefaultID;
            MyCode = DefaultCode;
            _useGrid.CheckOnClick = true;
            _useGrid.Click += new EventHandler(_useGrid_Click);
            ctx.Items.Add(_useGrid);
            this.ContextMenuStrip = ctx;
            // not cases sensitive
            this.CaseSensitive = false;
            // the list for our suggestions database
            // the sample dictionary en-EN.dic is stored here when form1 is loaded (see form1.Load event)
            this.AutoCompleteList = new List<string>();
            _grid = new ucGrid();
            // the listbox used for suggestions
            this.listBox = new ListBox();
            this.listBox.Name = "SuggestionListBox";
            this.listBox.Font = this.Font;
            this.listBox.Visible = true;
            this.listBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.listBox.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.listBox.ScrollAlwaysVisible = true;

            // the panel to hold the listbox later on
            this.panel = new Panel();
            this.panel.Visible = false;
            this.panel.Font = this.Font;
            // to be able to fit to changing sizes of the parent form
            this.panel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            // initialize with minimum size to avoid overlaping or flickering problems
            this.panel.ClientSize = new System.Drawing.Size(1, 1);
            this.panel.Name = "SuggestionPanel";
            this.panel.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
            this.panel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
            this.panel.BackColor = Color.Transparent;
            this.panel.ForeColor = Color.Transparent;
            this.panel.Text = "";
            this.panel.PerformLayout();
            // add the listbox to the panel if not already done
            if (!panel.Controls.Contains(listBox))
            {
                this.panel.Controls.Add(listBox);

            }
            if (!panel.Controls.Contains(_grid))
            {
                this.panel.Controls.Add(_grid);

            }
            // make the listbox fill the panel
            this.listBox.Dock = DockStyle.Fill;
            _grid.Dock = DockStyle.Fill;
            // only one itme can be selected from the listbox
            this.listBox.SelectionMode = SelectionMode.One;
            // the events to be fired if an item is selected
            this.listBox.KeyDown += new KeyEventHandler(listBox_KeyDown);
            this.listBox.MouseClick += new MouseEventHandler(listBox_MouseClick);
            this.listBox.MouseDoubleClick += new MouseEventHandler(listBox_MouseDoubleClick);
            this.listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged);
            #region Excursus: ArrayList vs. List<string>
            // surpringly ArrayList is a little faster than List<string>
            // to use ArrayList instead, replace every 'List<string>' with 'ArrayList'
            // i will used List<string> cause it's generic type
            #endregion Excursus: ArrayList vs. List<string>
            // the list of suggestions actually displayed in the listbox
            // a subset of AutoCompleteList according to the typed in keyphrase
            this.CurrentAutoCompleteList = new List<string>();
            this.CurrentAutoCompleteList_IDAndCode = new List<string>();
            this.CurrentAutoCompleteList_IDThuockho = new List<string>();

            #region Excursus: DataSource vs. AddRange
            // using DataSource is faster than adding items (see
            // uncommented listBox.Items.AddRange method below)
            #endregion Excursus: DataSource vs. AddRange
            // Bind the CurrentAutoCompleteList as DataSource to the listbox
            listBox.DataSource = CurrentAutoCompleteList;

            _grid._OnCellValueChanged += new ucGrid.OnCellValueChanged(_grid__OnCellValueChanged);
            _grid._OnKeyDown += new ucGrid.OnKeyDown(_grid__OnKeyDown);
            _grid._OnPreviewKeyDown += new ucGrid.OnPreviewKeyDown(_grid__OnPreviewKeyDown);
            _grid._OnSelectionChanged += new ucGrid.OnSelectionChanged(_grid__OnSelectionChanged);
            _grid.AllowedChanged = false;
            // set the input to remember, which is empty so far
            oldText = this.Text;
        }
        // the constructor
        public AutoCompleteTextbox_Thuoc()
            : base()
        {
            // assigning some default values
            // minimum characters to be typed before suggestions are displayed
            this.MinTypedCharacters = 2;
            ExtraWidth               = 0;
            ExtraWidth_Pre           = 0;
            GridView                 = true;
            RaiseEventEnter          = false;
            RaiseEventEnterWhenEmpty = false;
            DefaultCode              = "-1";
            DefaultID                = "-1";
            splitChar                = '@';
            splitCharIDAndCode       = '#';
            MaxHeight                = -1;
            RaiseEvent               = false;
            CompareNoID              = true;
            FillValueAfterSelect     = false;
            MyID   = DefaultID;
            MyCode = DefaultCode;
            _useGrid.CheckOnClick = true;
            _useGrid.Click       += new EventHandler(_useGrid_Click);
            ctx.Items.Add(_useGrid);
            this.ContextMenuStrip = ctx;
            // not cases sensitive
            this.CaseSensitive = false;
            // the list for our suggestions database
            // the sample dictionary en-EN.dic is stored here when form1 is loaded (see form1.Load event)
            this.AutoCompleteList = new List <string>();
            _grid = new ucGrid();
            // the listbox used for suggestions
            this.listBox                     = new ListBox();
            this.listBox.Name                = "SuggestionListBox";
            this.listBox.Font                = this.Font;
            this.listBox.Visible             = true;
            this.listBox.BackColor           = Color.FromKnownColor(KnownColor.Control);
            this.listBox.Font                = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.listBox.ScrollAlwaysVisible = true;


            // the panel to hold the listbox later on
            this.panel         = new Panel();
            this.panel.Visible = false;
            this.panel.Font    = this.Font;
            // to be able to fit to changing sizes of the parent form
            this.panel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            // initialize with minimum size to avoid overlaping or flickering problems
            this.panel.ClientSize = new System.Drawing.Size(1, 1);
            this.panel.Name       = "SuggestionPanel";
            this.panel.Padding    = new System.Windows.Forms.Padding(0, 0, 0, 0);
            this.panel.Margin     = new System.Windows.Forms.Padding(0, 0, 0, 0);
            this.panel.BackColor  = Color.Transparent;
            this.panel.ForeColor  = Color.Transparent;
            this.panel.Text       = "";
            this.panel.PerformLayout();
            // add the listbox to the panel if not already done
            if (!panel.Controls.Contains(listBox))
            {
                this.panel.Controls.Add(listBox);
            }
            if (!panel.Controls.Contains(_grid))
            {
                this.panel.Controls.Add(_grid);
            }
            // make the listbox fill the panel
            this.listBox.Dock = DockStyle.Fill;
            _grid.Dock        = DockStyle.Fill;
            // only one itme can be selected from the listbox
            this.listBox.SelectionMode = SelectionMode.One;
            // the events to be fired if an item is selected
            this.listBox.KeyDown              += new KeyEventHandler(listBox_KeyDown);
            this.listBox.MouseClick           += new MouseEventHandler(listBox_MouseClick);
            this.listBox.MouseDoubleClick     += new MouseEventHandler(listBox_MouseDoubleClick);
            this.listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged);
            #region Excursus: ArrayList vs. List<string>
            // surpringly ArrayList is a little faster than List<string>
            // to use ArrayList instead, replace every 'List<string>' with 'ArrayList'
            // i will used List<string> cause it's generic type
            #endregion Excursus: ArrayList vs. List<string>
            // the list of suggestions actually displayed in the listbox
            // a subset of AutoCompleteList according to the typed in keyphrase
            this.CurrentAutoCompleteList            = new List <string>();
            this.CurrentAutoCompleteList_IDAndCode  = new List <string>();
            this.CurrentAutoCompleteList_IDThuockho = new List <string>();

            #region Excursus: DataSource vs. AddRange
            // using DataSource is faster than adding items (see
            // uncommented listBox.Items.AddRange method below)
            #endregion Excursus: DataSource vs. AddRange
            // Bind the CurrentAutoCompleteList as DataSource to the listbox
            listBox.DataSource = CurrentAutoCompleteList;

            _grid._OnCellValueChanged += new ucGrid.OnCellValueChanged(_grid__OnCellValueChanged);
            _grid._OnKeyDown          += new ucGrid.OnKeyDown(_grid__OnKeyDown);
            _grid._OnPreviewKeyDown   += new ucGrid.OnPreviewKeyDown(_grid__OnPreviewKeyDown);
            _grid._OnSelectionChanged += new ucGrid.OnSelectionChanged(_grid__OnSelectionChanged);
            _grid.AllowedChanged       = false;
            // set the input to remember, which is empty so far
            oldText = this.Text;
        }