.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 2nd, 2007, 12:55 PM
RxOuchy RxOuchy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 1 RxOuchy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 43 sec
Reputation Power: 0
C# Textbox Focus question

Hello,

I have been searching around trying to find any information on how to use the arrow keys to change the focus on a textbox.

I am creating a program that has 3 text boxes that would contain a phone number. At the moment I have the focus change when the TextBox Length is equal 3 ... but I would like to be able to also use the keyboard to change the focus of the box. Say the user would make a mistake (typo) and want to go back by using the left arrow key...

But... I also would like it NOT to switch from 1 box to the other unless it is at the end of the textbox. If that makes sense. I want the arrow key to move through the entered numbers then switch to the next text box. So if they have entered their entire phone number and notice the second number is wrong... by hitting the arrow key it will take them through the last 4 numbers, then skip to the next text box, then move through those 3 numbers then skip to the next box, then move to his number he wants to change.

I hope this makes sence to you.

Here is a clip of what I have so far.


Code:
private void txtPhn1_TextChanged(object sender, EventArgs e) 
{ 
if (txtPhn1.TextLength == 3) 
{ 
txtPhn2.Focus(); 
} 
} 

private void txtPhn2_TextChanged(object sender, EventArgs e) 
{ 
if (txtPhn2.TextLength == 3) 
{ 
txtPhn3.Focus(); 
} 
else 
{ 
if (txtPhn2.TextLength == 0) 
{ 
txtPhn1.Focus(); 
} 
} 
} 

private void txtPhn3_TextChanged(object sender, EventArgs e) 
{ 
if (txtPhn3.TextLength == 0) 
{ 
txtPhn2.Focus(); 
} 
} 

private void btn1_Click(object sender, EventArgs e) 
{ 
StatusMsg("Phone Number: [ " + txtPhn1.Text + "-" + txtPhn2.Text + "-" + txtPhn3.Text + " ]"); 
}


Ty In advance

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > C# Textbox Focus question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT