接上面
private void lbMain_Click(object sender, System.EventArgs e)
        {
            if (lbMain.SelectedItems.Count == 0)
                return;
            string strSel = lbMain.SelectedItem.ToString();
            this.Text = strSel;
            int iSel = this.FindStringExact(Text);
            if (iSel != -1)
                this.SelectedIndex = iSel;
            lbMain.Visible = false;
        }        
        protected override void OnTextChanged(EventArgs e)
        {
            if (!DesignMode)
            {
                if (isselect == true)
                {
                    lbMain.Visible = false;
                    isselect = false;
                    base.OnTextChanged(e);
                    return;
                }
                if (Text == "")
                {
                    lbMain.Visible = false;
                    base.OnTextChanged(e);
                    return;
                }
                if (!this.Parent.Controls.Contains(lbMain))
                {
                    lbMain.Width = this.Width+50;
                    lbMain.Height = 200;
                    lbMain.Parent = this.Parent;
                    lbMain.Top = this.Top + this.Height + 1;
                    lbMain.Left = this.Left;
                    this.Parent.Controls.Add(lbMain);
                    lbMain.BringToFront();
                }
                ArrayList alFill = GetFillList(Text);
                lbMain.Items.Clear();
                base.OnTextChanged(e);
                lbMain.Items.AddRange(alFill.ToArray());
                if (lbMain.Items.Count > 0)
                    lbMain.SelectedIndex = 0;
                if (!lbMain.Visible && this.Focused)
                    lbMain.Visible = true;
            }
            base.OnTextChanged(e);        }        protected override void OnLocationChanged(EventArgs e)
        {
            if (!DesignMode)
            {
                if (lbMain != null)
                {
                    SetlbMainLocation();
                }
            }
        }        private void SetlbMainLocation()
        {
            lbMain.Visible = false;
            lbMain.Width = this.Width+50;
            lbMain.Height = 200;
            lbMain.Top = this.Top + this.Height + 1;
            lbMain.Left = this.Left;
            lbMain.BringToFront();
        }        protected override void OnLeave(EventArgs e)
        {
            if (!DesignMode)
            {
                if (!lbMain.Focused && !this.Focused)
                    lbMain.Visible = false;
            }
            base.OnLeave(e);
        }
        protected override void OnDropDown(EventArgs e)
        {
            lbMain.Visible = false;
            isselect = true;
            base.OnDropDown(e);
        }        protected override void OnVisibleChanged(EventArgs e)
        {
            if (!DesignMode)
            {
                if (!this.Visible)
                {
                    if (lbMain != null)
                    {
                        lbMain.Visible = false;
                    }
                }
            }
            base.OnVisibleChanged(e);
        }        protected override void OnKeyDown(KeyEventArgs e)
       {
            if (lbMain.Visible)
            {
                if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left ||
                     e.KeyCode == Keys.Right || e.KeyCode == Keys.PageDown || e.KeyCode == Keys.PageUp)
                {
                    lbMain_KeyDown(lbMain, e);
                    e.Handled = true;
                }
                else if (e.KeyCode == Keys.Enter)
                {
                    lbMain_Click(lbMain, e);
                    e.Handled = true;
                }
                else if (e.KeyCode == Keys.Back)
                {
                    if (this.Text == "")
                    {
                        lbMain.SelectedIndex = -1;
                    }
                }
            }
            base.OnKeyDown(e);
        }        private void lbMain_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Left || e.KeyCode == Keys.PageUp)
            {
                if (lbMain.SelectedIndex > 0)
                    lbMain.SelectedIndex = lbMain.SelectedIndex - 1;
            }
            else if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Right || e.KeyCode == Keys.PageDown)
            {
                if (lbMain.SelectedIndex < lbMain.Items.Count - 1)
                    lbMain.SelectedIndex = lbMain.SelectedIndex + 1;
            }
        }        private void UComboBoxEx_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (!DesignMode)
            {
                lbMain.Visible = false;
            }
        }        static public string GetChineseSpell(string strText)
        {
            int len = strText.Length;
            string myStr = "";
            for (int i = 0; i < len; i++)
            {
                myStr += getSpell(strText.Substring(i, 1));
            }
            return myStr;
        }        static public string getSpell(string cnChar)
        {
            byte[] arrCN = Encoding.Default.GetBytes(cnChar);
            if (arrCN.Length > 1)
            {
                int area = (short)arrCN[0];
                int pos = (short)arrCN[1];
                int code = (area << 8) + pos;
                int[] areacode = { 45217, 45253, 45761, 46318, 46826, 47010, 47297, 47614, 48119, 48119, 49062, 49324, 49896, 50371, 50614, 50622, 50906, 51387, 51446, 52218, 52698, 52698, 52698, 52980, 53689, 54481 };
                for (int i = 0; i < 26; i++)
                {
                    int max = 55290;
                    if (i != 25) max = areacode[i + 1];
                    if (areacode[i] <= code && code < max)
                    {
                        return Encoding.Default.GetString(new byte[] { (byte)(65 + i) });
                    }
                }
                return "*";
            }
            else
                return cnChar;
        }
    }
}