0

I'm trying to catch the TAB key event, but it dosen't work, I tried using this code, but still no result, wath should I do :

 protected override bool IsInputKey(Keys keyData)
    {
        if (keyData == Keys.Tab)
            return true;
        return base.IsInputKey(keyData);
    }

pleas help! Thanks!

I'm trying to do this:

        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);
            }
        }
    }
XandrUu
  • 1,169
  • 4
  • 26
  • 46
  • 1
    is this in Winforms? if so, it has been answered in SO previously: http://stackoverflow.com/questions/2461512/how-to-intercept-capture-tab-key-in-winforms-application – Krishna Mar 02 '12 at 09:09

1 Answers1

0

Try and use a message filter:

I'm not sure I use the right key for tab here, try and find the right one here: 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;
    }

Edit: I think the right key is 0x0100

Peter
  • 59
  • 6