无法捕获TAB keyUp

时间:2012-03-02 09:05:59

标签: c#

我正在尝试捕获TAB键事件,但它不起作用,我尝试使用此代码,但仍然没有结果,我应该做什么:

 protected override bool IsInputKey(Keys keyData)
    {
        if (keyData == Keys.Tab)
            return true;
        return base.IsInputKey(keyData);
    }
请求帮助! 谢谢!

我正在尝试这样做:

        private void comboBox1_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
        {
            try
            {
                DataView dv = glObalDataSet.Tables["JOBURI"].DefaultView;
                dv.RowFilter = "CONT = '" + comboBox1.SelectedValue.ToString() + "'";
                comboBox2.DataSource = LoadDataTable(dv);
                comboBox2.DisplayMember = "JOB";

                comboBox2.AutoCompleteCustomSource = LoadAutoComplete("JOB", dv);
                comboBox2.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                comboBox2.AutoCompleteSource = AutoCompleteSource.CustomSource;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

1 个答案:

答案 0 :(得分:0)

尝试使用邮件过滤器:

我不确定我是否在此处使用了正确的键,请尝试在此处找到正确的键:http://www.woodmann.com/fravia/sources/WINUSER.H

// Add IMessageFilter to the form
public partial class Form1 : Form, IMessageFilter

    public bool PreFilterMessage(ref Message m)
    {
        if (m.Msg == 0x0100)
            {
        {
            DataView dv = glObalDataSet.Tables["JOBURI"].DefaultView;
            dv.RowFilter = "CONT = '" + comboBox1.SelectedValue.ToString() + "'";
            comboBox2.DataSource = LoadDataTable(dv);
            comboBox2.DisplayMember = "JOB";

            comboBox2.AutoCompleteCustomSource = LoadAutoComplete("JOB", dv);
            comboBox2.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            comboBox2.AutoCompleteSource = AutoCompleteSource.CustomSource;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
                return true;
            }
        return false;
    }

编辑:我认为右键是0x0100