473,763 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Modifi erKeys == Keys.Tab),
checked for it by
MessageBox.Show ((e.KeyValue).T oString()); (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 5034
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.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;

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

public Form1() {InitializeComp onent();}

#region Windows Form Designer generated code
private void InitializeCompo nent() {
this.textBox1 = new TextBox2();
this.SuspendLay out();
//
// textBox1
//
this.textBox1.L ocation = new System.Drawing. Point(16, 16);
this.textBox1.N ame = "textBox1";
this.textBox1.S ize = new System.Drawing. Size(224, 20);
this.textBox1.T abIndex = 0;
this.textBox1.T ext = "textBox1";
this.textBox1.K eyDown += new
System.Windows. Forms.KeyEventH andler(this.tex tBox1_KeyDown);
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 273);
this.Controls.A dd(this.textBox 1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);

}
#endregion

private void textBox1_KeyDow n(object sender,
System.Windows. Forms.KeyEventA rgs e) {
MessageBox.Show (e.KeyCode.ToSt ring());
}
}

public class TextBox2:TextBo x {
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*******@disc ussions.microso ft.com> a écrit dans le message de
news:C2******** *************** ***********@mic rosoft.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.Modifi erKeys == Keys.Tab),
checked for it by
MessageBox.Show ((e.KeyValue).T oString()); (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.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;

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

public Form1() {InitializeComp onent();}

#region Windows Form Designer generated code
private void InitializeCompo nent() {
this.textBox1 = new TextBox2();
this.SuspendLay out();
//
// textBox1
//
this.textBox1.L ocation = new System.Drawing. Point(16, 16);
this.textBox1.N ame = "textBox1";
this.textBox1.S ize = new System.Drawing. Size(224, 20);
this.textBox1.T abIndex = 0;
this.textBox1.T ext = "textBox1";
this.textBox1.K eyDown += new
System.Windows. Forms.KeyEventH andler(this.tex tBox1_KeyDown);
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 273);
this.Controls.A dd(this.textBox 1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);

}
#endregion

private void textBox1_KeyDow n(object sender,
System.Windows. Forms.KeyEventA rgs e) {
MessageBox.Show (e.KeyCode.ToSt ring());
}
}

public class TextBox2:TextBo x {
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*******@disc ussions.microso ft.com> a écrit dans le message de
news:C2******** *************** ***********@mic rosoft.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.Modifi erKeys == Keys.Tab),
checked for it by
MessageBox.Show ((e.KeyValue).T oString()); (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
1557
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 as it was given to me from Imageready but it won't work. The event that i wanted (and "created" with Imageready) was ondown. The code is this: ONMOUSEOUT="changeImages('company', 'Images/company.gif'); return true;"...
4
2298
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' Help me to sort this out, it has taken me almost a week to wade through and it still won't work. Select Case Forms("frmForce").OpenArgs
4
3073
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 user control. The problem is, no matter what even when no data is filled out in the form, the submit button just postsback the page and nothing happens. I have 2 dummy links on the page right now, and the form is automatically created without a...
7
1776
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 complicated) to figured it out that this won't work because of attribute of a page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> I have visual studio 2005 beta2 and it appends this attribute to every...
3
5057
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 the network share. It loads in VS2005 fine, and I can edit and save code changes etc, but when I try and Build the solution, I get the following error... An error occured loading a configuration file: Failed to start monitoring
6
4205
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 help! bjorn
7
11202
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 type or namespace name 'Excel' could not be found". the error points to line in my code: "public Excel.Application ExcelObj = null".
2
2746
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 javascript that works fine until I try to separate the script into a .js file. I've found that only the script that is called from events set in the aspx.cs file don't work. I eliminated all script except two functions. One is used with the .cs file...
4
2507
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 extra copy of it called Natvrdo, since I modified the logo. Okay, I have this in my HTML (Natvrdo being the CSS style sheet) This is what I have in my index.html:
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.