User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 391,608 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,646 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Views: 5908 | Replies: 6
Reply
Join Date: May 2007
Posts: 5
Reputation: erfanjan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
erfanjan erfanjan is offline Offline
Newbie Poster

Help Change Focus in textbox

  #1  
May 5th, 2007
i write one program that have mant textbox for entry data into database but i want when user enter data in textbox and press 'Enter' ,change focus to another textbox.

can anyone have idea for hep me?
thanks.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,663
Reputation: iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice 
Rep Power: 16
Solved Threads: 297
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Change Focus in textbox

  #2  
May 6th, 2007
This is well documented on the net. What have you searched for?
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Nov 2006
Location: Bonners Ferry, ID
Posts: 279
Reputation: JerryShaw is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 38
JerryShaw JerryShaw is offline Offline
Posting Whiz in Training

Re: Change Focus in textbox

  #3  
May 8th, 2007
Look at
http://msdn2.microsoft.com/en-us/lib...s.keychar.aspx
then after e.Handled = true; set focus to the next control / textbox.
Reply With Quote  
Join Date: May 2007
Posts: 5
Reputation: erfanjan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
erfanjan erfanjan is offline Offline
Newbie Poster

Re: Change Focus in textbox

  #4  
May 9th, 2007
Originally Posted by JerryShaw View Post
Look at
http://msdn2.microsoft.com/en-us/lib...s.keychar.aspx
then after e.Handled = true; set focus to the next control / textbox.


thanks for your replay,
but when i press enter corsur hide and don't set next focus.
if (e.KeyChar == (char)13)//press Enter Key
{
Control currCtl = (Control)sender; //current control
e.Handled = true;
Control c = GetNextControl(currCtl, true);
c.Focus();
}

please send the error of this code.

thank you very much..
Reply With Quote  
Join Date: Nov 2006
Location: Bonners Ferry, ID
Posts: 279
Reputation: JerryShaw is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 38
JerryShaw JerryShaw is offline Offline
Posting Whiz in Training

Re: Change Focus in textbox

  #5  
May 11th, 2007
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
e.Handled = true;
Control c = GetNextControl((Control)sender, true);
if (c != null)
c.Focus();
}

This works fine.
Reply With Quote  
Join Date: Jul 2008
Posts: 1
Reputation: lethingocphuong is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
lethingocphuong lethingocphuong is offline Offline
Newbie Poster

Re: Change Focus in textbox

  #6  
Jul 8th, 2008
Thanks JerryShaw a lot.
Last edited by lethingocphuong : Jul 8th, 2008 at 11:52 pm.
Reply With Quote  
Join Date: Mar 2007
Posts: 48
Reputation: FaridMasood is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
FaridMasood's Avatar
FaridMasood FaridMasood is offline Offline
Light Poster

Re: Change Focus in textbox

  #7  
Jul 9th, 2008
in the key down event of text box write this code
if e.KeyCode=Keys.Enter then
send.keys("tab")
end if
Thanks and Best of Lusk,

Farid ud din Masood
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C# Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 12:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC