473,394 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

KeyCode & KeyValue won't work for Tab???

Hi,
Just checking to see if there's anything I can possibly do to allow for the
recognition of the Tab key being pressed. On the KeyDown event I've tried:

if (e.KeyCode == Keys.Tab),
if (Control.ModifierKeys == Keys.Tab),
checked for it by
MessageBox.Show((e.KeyValue).ToString()); (it responded to every key I tried
except for Tab)),

even entered
protected override bool IsInputKey(Keys keyData)
{
if (keyData==Keys.Tab) return true;
return base.IsInputKey (keyData);
}
from a reply someone else got on the same subject (it worked for them, so
maybe I did something wrong? - I put it at the beginning of my program and
then tried the keycode thing again).

The Tab key tabs just fine, it just won't do anything else.
Thanks so much for any help!!!!
Yours frustrated,
Mel
Nov 17 '05 #1
2 5001
I think you did not properly used the code for IsInputKey. It must be the
overriden method of the control you want Tab key be caught.

Try the following lines (copy/paste it in a new project) :
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form {
private TextBox2 textBox1;
[STAThread]
static void Main() {Application.Run(new Form1());}

public Form1() {InitializeComponent();}

#region Windows Form Designer generated code
private void InitializeComponent() {
this.textBox1 = new TextBox2();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(16, 16);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
this.textBox1.KeyDown += new
System.Windows.Forms.KeyEventHandler(this.textBox1 _KeyDown);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e) {
MessageBox.Show(e.KeyCode.ToString());
}
}

public class TextBox2:TextBox {
protected override bool IsInputKey(Keys keyData) {
if (keyData==Keys.Tab) return true;
return base.IsInputKey (keyData);
}
}

It should work fine.

Hope it helps,

Ludovic SOEUR.

"melanieab" <me*******@discussions.microsoft.com> a écrit dans le message de
news:C2**********************************@microsof t.com...
Hi,
Just checking to see if there's anything I can possibly do to allow for the recognition of the Tab key being pressed. On the KeyDown event I've tried:
if (e.KeyCode == Keys.Tab),
if (Control.ModifierKeys == Keys.Tab),
checked for it by
MessageBox.Show((e.KeyValue).ToString()); (it responded to every key I tried except for Tab)),

even entered
protected override bool IsInputKey(Keys keyData)
{
if (keyData==Keys.Tab) return true;
return base.IsInputKey (keyData);
}
from a reply someone else got on the same subject (it worked for them, so
maybe I did something wrong? - I put it at the beginning of my program and
then tried the keycode thing again).

The Tab key tabs just fine, it just won't do anything else.
Thanks so much for any help!!!!
Yours frustrated,
Mel

Nov 17 '05 #2
That worked! Thanks so much!!!
Mel

"Ludovic SOEUR" wrote:
I think you did not properly used the code for IsInputKey. It must be the
overriden method of the control you want Tab key be caught.

Try the following lines (copy/paste it in a new project) :
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form {
private TextBox2 textBox1;
[STAThread]
static void Main() {Application.Run(new Form1());}

public Form1() {InitializeComponent();}

#region Windows Form Designer generated code
private void InitializeComponent() {
this.textBox1 = new TextBox2();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(16, 16);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
this.textBox1.KeyDown += new
System.Windows.Forms.KeyEventHandler(this.textBox1 _KeyDown);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e) {
MessageBox.Show(e.KeyCode.ToString());
}
}

public class TextBox2:TextBox {
protected override bool IsInputKey(Keys keyData) {
if (keyData==Keys.Tab) return true;
return base.IsInputKey (keyData);
}
}

It should work fine.

Hope it helps,

Ludovic SOEUR.

"melanieab" <me*******@discussions.microsoft.com> a écrit dans le message de
news:C2**********************************@microsof t.com...
Hi,
Just checking to see if there's anything I can possibly do to allow for

the
recognition of the Tab key being pressed. On the KeyDown event I've

tried:

if (e.KeyCode == Keys.Tab),
if (Control.ModifierKeys == Keys.Tab),
checked for it by
MessageBox.Show((e.KeyValue).ToString()); (it responded to every key I

tried
except for Tab)),

even entered
protected override bool IsInputKey(Keys keyData)
{
if (keyData==Keys.Tab) return true;
return base.IsInputKey (keyData);
}
from a reply someone else got on the same subject (it worked for them, so
maybe I did something wrong? - I put it at the beginning of my program and
then tried the keycode thing again).

The Tab key tabs just fine, it just won't do anything else.
Thanks so much for any help!!!!
Yours frustrated,
Mel


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim | last post by:
Hey guys I DESPERATLY need some help with this small javascript i have on this website. All that it's supposed to do is change the button image once it's pressed but alas... I copy-pasted the code...
4
by: Mark | last post by:
the Following bit of code doesn't work. It seems to respond to the second, starting with 'add iif statement for Good Practice', but not to the first, starting 'add iif statement for archived' ...
4
by: Chad | last post by:
I have a link (.ascx) and that generates an Add form on that page. The autopostback dropdown is within a "If Not IsPostBack Then" statement. The form that is created is all via static html in the...
7
by: simon | last post by:
I have simple html(aspx) page, but vertical height won't work. Even if i had set the height of a table=100%, the table is not 100% height. I spend a lot of time(my real page is more...
3
by: musosdev | last post by:
Hi guys Okay, I've setup my projects to open and compile fine in VS2005 using FPSE and remote web, but it's *really* slow. So I thought I'd have a go at doing it the normal way, by loading from...
6
by: b. hotting | last post by:
Hi, I don't see why this won't work, it are 3 links, the last one (a get) does work, but the first 2 won't. i would like to use a post, through hidden input types any idea? thanks for your...
7
by: Eran.Yasso | last post by:
Hi, I have project that automate excel(using Excel COM) which works fine in my home. I took the project from my home to work and tried to build the project but it won't built. I get error "The...
2
by: Matthew Wells | last post by:
Hello. I'm reposting this because my prioe post's subject line was incorrect. I'm developing an asp.net 2.0 project using VS 2005 on XP sp2 with all the updates. I have an aspx page with...
4
by: z55177 | last post by:
My domain: http://www.esthevision.cz/ This is the cause of my problem. The template is supposed to look somewhat like this: PINK STRIPE http://themebot.com/website-templates/ht... I created an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.