473,473 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do i programatically tab to the next field?

Hi,

I want to make the enter key in certain fields do the same as the tab key

I've caught the KeyPress event for the enter key, however I cannot find the
function to call in order to tab to the next field??

I just want to do a generic event handler, so if i need to specify a tab
number can i get the tab index of the current field from:

Private Sub EnterHandler(ByVal sender As System.Object, ByVal e As
KeyPressEventArgs)

sender?
Thanks!
Dan
Nov 20 '05 #1
8 1984
You can use the GetNextControl Method of the control you want to move from.
After capturing the Enter key then get the next control and then set the
focus to that control.
Lloyd Sheen

"Dan Keeley" <ma********@hotmail.com> wrote in message
news:7t***************@newsfe5-gui.server.ntli.net...
Hi,

I want to make the enter key in certain fields do the same as the tab key

I've caught the KeyPress event for the enter key, however I cannot find the function to call in order to tab to the next field??

I just want to do a generic event handler, so if i need to specify a tab
number can i get the tab index of the current field from:

Private Sub EnterHandler(ByVal sender As System.Object, ByVal e As
KeyPressEventArgs)

sender?
Thanks!
Dan

Nov 20 '05 #2
* "Dan Keeley" <ma********@hotmail.com> scripsit:
I want to make the enter key in certain fields do the same as the tab key

I've caught the KeyPress event for the enter key, however I cannot find the
function to call in order to tab to the next field??


\\\
Me.GetNextControl(Me.ActiveControl, False).Focus()
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
>
\\\
Me.GetNextControl(Me.ActiveControl, False).Focus()
///


Hmm, that sounds perfect, except that it doesnt work. Focus appears to go
nowhere... Nothing clearly has focus and if i then tab it seems to return
to the field i was just trying to get out of!?

I've double checked the component i'm on, and tab index is indeed
consecutive... Is that not the numeric ordering it uses?

How can i find out where focus is?

Rgds,
Dam
Nov 20 '05 #4
* "Dan Keeley" <ma********@hotmail.com> scripsit:
How can i find out where focus is?


'Me.ActiveControl' will return a reference to the active control.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2i************@uni-berlin.de...
* "Dan Keeley" <ma********@hotmail.com> scripsit:
How can i find out where focus is?


'Me.ActiveControl' will return a reference to the active control.


Excellent that helped me fix the problem.

Thanks loads!!!
Dan
Nov 20 '05 #6
Hi,

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If Asc(e.KeyChar) = 13 Then
e.Handled = True
SendKeys.Send("{TAB}")
End If

End Sub
From:
yu**********@yahoo.com
http://www.geocities.com/yulyos4vbnet
http://www.geocities.com/yulyos
Development and writing software programs
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7
Yos Yul,
Have you tried SelectNextControl?

Something like:
If e.KeyChar = ControlChars.Cr Then
e.Handled = True Me.SelectNextControl(TextBox1, True, True, True, True) End If
Be certain to read the help on the four parameters that I made True.

Hope this helps
Jay

"yos yul" <yu**********@yahoo.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl... Hi,

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If Asc(e.KeyChar) = 13 Then
e.Handled = True
SendKeys.Send("{TAB}")
End If

End Sub
From:
yu**********@yahoo.com
http://www.geocities.com/yulyos4vbnet
http://www.geocities.com/yulyos
Development and writing software programs
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #8
Hi,

Yes I tried:

Me.SelectNextControl(TextBox1, True, True, True, True)

and it is very nice.

Have a nice day

From:
yu**********@yahoo.com
http://www.geocities.com/yulyos4vbnet
http://www.geocities.com/yulyos
Development and writing software programs
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #9

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

Similar topics

3
by: Gil | last post by:
Hello, I use VB.NET and have a series of linkbuttons that are inside individual <td>s. Like this: <td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td> I would like...
0
by: CoreyMas | last post by:
Hello Everyone, I have been successful in creating a template column programatically using the examples provided in VS 2003. However I have not been able to programatically set the width of a...
2
by: LaurenW | last post by:
Hi folks, I just discovered that I have a table with a bunch of text fields that ALL have the "Allow Zero Length" property set to "No", which is apparently the default when you create a new text...
3
by: Tym | last post by:
OK - daft question of the day time... If I have database A which contains all the live data, and Database B which contains linked tables to those is A (i.e. a front end) is there a way of seeing...
1
by: Richard Hollenbeck | last post by:
I have a report that is dynamically naming the columns and rows, etc., but I have way more columns (at least 37 at this time) than will fit on the report comfortably. So I have ten columns on the...
2
by: Richard Hollenbeck | last post by:
I use a temporary table to assemble unrelated data for specific forms and reports. After each use of this table, I have a delete query which empties the table out for its next use. I have one...
4
by: Andrea Williams | last post by:
Does anyone know of some in depth documentation regarding how to add user controls programatically? I have a User Control, which has some basic html controls, and depending on the number selected...
3
by: Carl Mercier | last post by:
Hi, I have a long form that post back to itself at different places. At the very end, I have a button called "Next" that post back to itself again but some panels are hidden and some others are...
1
by: Carl Mercier | last post by:
Hi, I have a long form that post back to itself at different places (different controls). At the very end, I have a button called "Next" that post back to itself again causing some panels to be...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.