473,799 Members | 2,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tabbing Through Controls

8 New Member
I would like to Programmaticall y move from one control to another following the TabIndex. If the user were to fill the maximum length of any one of a number of TextBoxs they would automatically be moved to the next TextBox.

I have written this, and it works. It loops through each control until it finds the TabIndex + 1. But there must be a better way. Any ideas?

Expand|Select|Wrap|Line Numbers
  1.     Private Sub MoveToNextControl(ByVal Sender As TimeControl) Handles AttendanceControlMondayStartDay.NextControl, AttendanceControlMondayStartLunch.NextControl, etc....
  2.         'This is to go to the next Control in the TabIndex
  3.         Dim i As Integer, intCurrentTabPlus1 As Integer = Sender.TabIndex + 1
  4.         For i = 1 To Panel1.Controls().Count - 1
  5.             If Panel1.Controls(i).TabIndex = intCurrentTabPlus1 Then
  6.                 Panel1.Controls(i).Focus()
  7.                 Exit Sub
  8.             End If
  9.         Next
  10.     End Sub
Thanks!!
May 22 '07 #1
7 1736
Dököll
2,364 Recognized Expert Top Contributor
I would like to Programmaticall y move from one control to another following the TabIndex. If the user were to fill the maximum length of any one of a number of TextBoxs they would automatically be moved to the next TextBox.

I have written this, and it works. It loops through each control until it finds the TabIndex + 1. But there must be a better way. Any ideas?

Expand|Select|Wrap|Line Numbers
  1.     Private Sub MoveToNextControl(ByVal Sender As TimeControl) Handles AttendanceControlMondayStartDay.NextControl, AttendanceControlMondayStartLunch.NextControl, etc....
  2.         'This is to go to the next Control in the TabIndex
  3.         Dim i As Integer, intCurrentTabPlus1 As Integer = Sender.TabIndex + 1
  4.         For i = 1 To Panel1.Controls().Count - 1
  5.             If Panel1.Controls(i).TabIndex = intCurrentTabPlus1 Then
  6.                 Panel1.Controls(i).Focus()
  7.                 Exit Sub
  8.             End If
  9.         Next
  10.     End Sub
  11.  
  12. Thanks!!
Greetings, gtyler!

Good of you to add your code, helps a great deal, please give me a minute to search for an answer...

Dököll
May 23 '07 #2
Dököll
2,364 Recognized Expert Top Contributor
Greetings, gtyler!

Good of you to add your code, helps a great deal, please give me a minute to search for an answer...

Dököll
Ok, wait, do you mean to say, when a user reaches a certain number of hits within a form with textboxes to then fir up another form with additional textboxes?
May 23 '07 #3
gtyler
8 New Member
Ok, wait, do you mean to say, when a user reaches a certain number of hits within a form with textboxes to then fir up another form with additional textboxes?
Thanks so much for looking at this!

No... it is a timesheet programme. The idea is to make it as easy as possible for people to fill in their times. So once they have entered the time they got into work in one Custom Controls (in effect a TextBox), it moves straight to the next box (which would have the next number in the Tabindex) eg when you went for lunch.

By using the TabIndex I wanted to bypass writting extra code for any subsequent controls I might need to add.

I got arround the problem by looping through each of my Custom Controls (in effect TextBoxes) and checking if that Control's Tabindex was the next one in the order. If it was then it would set the Control's focus. But looping through each control seems an expensive way of just moving to the next control?
May 23 '07 #4
Dököll
2,364 Recognized Expert Top Contributor
I got arround the problem by looping through each of my Custom Controls (in effect TextBoxes) and checking if that Control's Tabindex was the next one in the order. If it was then it would set the Control's focus. But looping through each control seems an expensive way of just moving to the next control?
Quite welcome, I think I see what you mean, I wonder if setting focus to the next available textbox would do it:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Panel1.SetFocus
  3.  
  4.  
Whereby after user enters time, settting focus to next available seat would be automatic.

How 'bout that? Not sure if above will work cannot run anything here. Give me 'til tonight to grab my notebook...
May 24 '07 #5
gtyler
8 New Member
Quite welcome, I think I see what you mean, I wonder if setting focus to the next available textbox would do it:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Panel1.SetFocus
  3.  
  4.  
Whereby after user enters time, settting focus to next available seat would be automatic.

How 'bout that? Not sure if above will work cannot run anything here. Give me 'til tonight to grab my notebook...
------------------------------------------------------------

No... I did set the focus to the next control in my original code like this:

Panel1.Controls (i).Focus()

Where 'i' is an iterated integer that went through each of the controls. What I was hoping to find out was for a given control which control would I need to set the focus to next? Which is the next control with in the TabIndex?
May 28 '07 #6
Killer42
8,435 Recognized Expert Expert
------------------------------------------------------------

No... I did set the focus to the next control in my original code like this:

Panel1.Controls (i).Focus()

Where 'i' is an iterated integer that went through each of the controls. What I was hoping to find out was for a given control which control would I need to set the focus to next? Which is the next control with in the TabIndex?
It's a fascinating problem. However, I wonder whether you might be able to shortcut the whole thing by using SendKeys to send a "tab" keypress. :)

Otherwise, I suspect you might be stuck with your current method, which is quite cleverly implemented.
May 29 '07 #7
gtyler
8 New Member
It's a fascinating problem. However, I wonder whether you might be able to shortcut the whole thing by using SendKeys to send a "tab" keypress. :)

Otherwise, I suspect you might be stuck with your current method, which is quite cleverly implemented.

Ahh... I see what you mean. Not really what I was looking for but it might do the trick. Thank you so much for looking into this for me!
May 29 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2225
by: Richard | last post by:
Tabbing from the first control on a form always sends me to IE's Address Bar instead of the next control, no matter how I set the TabIndex property for the controls. Why is this happening? For example, I have a simple login screen with 2 textboxes (Login ID and Password) and 2 buttons (Login and Cancel). I've set the TabIndex Property of each control, starting at 0. When I enter a login id and then press Tab, the focus goes to IE's...
0
1157
by: Nick | last post by:
Hi, I have a requirement to build a mouse free windows application and have to hence rely heavily on the tabbing indices. However, I'm facing some issues when the tab goes to a datagrid. It shows very random behavior when the focus is on the last cell. It sometimes skips the next control to give focus to the one after that, and sometimes even skips 2 controls. Also, when you try and navigate back with shift+tab, it again skips quite a...
2
2308
by: rmiller | last post by:
I'm in dire straits. I'm converting part of a product into VB.NET, but still need to access forms written in VB 6.0. I've got just about everyting working, but the tabbing on the form. The form captures the tab key when it's pressed, but fails to go through the series of controls. Help!
6
2246
by: Doug Bell | last post by:
Hi I have a DataGrid with some hidden columns and also some read Only and some ComboBox Columns. Sandard Tabbing through the Datagrid sees the focus go to the hidden columns requiring further Tabbing to get to the desired column but it works fine stopping correctly on the ComboBox column. I have built a routine to test whether the use is Tabbing forward or back (Shift Tab) by looking at the last location, not by trapping the Keys. If
3
2625
by: Ty | last post by:
I am creating a ASP.net project and I wanted to make it so that when the user tabs on on of my pages that they do not have to tab through some controls. Is there a way to skip controls while tabbing? Thanks, Ty
0
9685
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
9538
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
10473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10219
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
10025
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
9068
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6804
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
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...
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.