Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Tab Index (controlling Tab order)
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
McKenzie




PostPosted: Mon May 22, 2006 8:41 am   Post subject: Tab Index (controlling Tab order)

Controlling the Tab Oder in VB is fairly basic. There are two properties that you need to look at: Tab Index and Tab Stop. When your application starts the control with Tab Index zero will get focus then as you hit the tab key focus will jump, in Tab Index order, from control to control. If you don't want a control to get focus by hitting the tab key set its Tab Stop to false.

Basic Design Tips
~~~~~~~~~~~
Western Society reads left to right, top to bottom. Your form should follow that basic order. There are times when you want to deviate from this but at very least start in the top left corner and finish in the bottom right.

Why do labels have a tab Index if you can never give them focus? Your labels should have a Tab Index one less than the text box that it is being the label for. Give your label a keyboard shortcut (by placing an & before the shortcut key in the caption property) then when the user uses the shortcut to the label the text box will get focus.
Sponsor
Sponsor
Sponsor
sponsor
ToughRouge




PostPosted: Mon May 22, 2006 8:48 am   Post subject: (No subject)

I see... thanks for the tip... but how do you make a tab?
cool dude




PostPosted: Mon May 22, 2006 12:04 pm   Post subject: (No subject)

to make the tab its really simple. basically double click on your form. once your code window opens change the event on your form to keypress. then type in this code:

code:

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 9 Then
        TabIndex = 1
    End If
End Sub


i hope this helps!
ToughRouge




PostPosted: Mon May 22, 2006 12:12 pm   Post subject: (No subject)

I don't see the tabs. =/... I'm a beginner in VB so I probably did something wrong. Sad
But I also want to know... when you switch between tabs, do you load a different form, or is it just a different page in the form or something?
GlobeTrotter




PostPosted: Mon May 22, 2006 2:04 pm   Post subject: (No subject)

I think there is some major miscommunication going on. From what I gather, ToughRouge is reffering to tab objects, ones you click on that act like frames. McKenzie is refering to the order things are hilighted when you actually press the tab key.

I'm not entirely sure, ToughRouge, but I believe you will have to press CTRL+T on the form and look for a tab object. Then, you can simply drag it onto the form.
McKenzie




PostPosted: Mon May 22, 2006 6:44 pm   Post subject: (No subject)

Opps Embarassed , you mean the TabStrip control. Not quite as easy. The TabStrip does not work quite as nicely as you would like it to. You would expect that at design time you could simply paint stuff on each of the Tabs and let VB handle stuff in the background. Not so. OK, here is how it works:

1. Add the cutom control: R-Click the tool, Components, MS Common Controls 6.0. Draw on your TabStrip.

2. Set the properties. There are loads of properties with TabStrips. The most important is the setting of the actual Tabs. To do this access the custom property (or R-Click, properties) go to the Tabs tab and your tabs and set their captions.

3. The Best way to set up the contents for the TabStrip is to have a control array of Frames. Set the borders of the frames to none and the visibility of all but the first one to false.

4. As the user selects Tabs set the visibility of the respective frame to true and the old one to false.

I've included an example.



Form1.frm
 Description:

Download
 Filename:  Form1.frm
 Filesize:  5.34 KB
 Downloaded:  482 Time(s)


Project1.vbp
 Description:

Download
 Filename:  Project1.vbp
 Filesize:  749 Bytes
 Downloaded:  438 Time(s)

ToughRouge




PostPosted: Mon May 22, 2006 8:17 pm   Post subject: (No subject)

Thanks for the example, I get it now.

But whats the difference between TabStrip Control and the SSTab Control that you can find on Microsoft Tab Dialog Control 6.0 (SP6). On the Tab Dialog control, I find that you don't have to use the frames to make things visible or not. So... which one is better?

I attached a crude example of what I was talking about.



The Extension 'frx' was deactivated by an board admin, therefore this Attachment is not displayed.


TaBS.vbp
 Description:

Download
 Filename:  TaBS.vbp
 Filesize:  690 Bytes
 Downloaded:  425 Time(s)


frmTabs.frm
 Description:

Download
 Filename:  frmTabs.frm
 Filesize:  4.32 KB
 Downloaded:  553 Time(s)

McKenzie




PostPosted: Tue May 23, 2006 7:31 am   Post subject: (No subject)

I'm sure there is a reason for using the TabStrip, but you're right the ssTab is much easier.
Sponsor
Sponsor
Sponsor
sponsor
ToughRouge




PostPosted: Tue May 23, 2006 6:49 pm   Post subject: (No subject)

OK, for the SSTab, I still have one question... The conventional naming thing ( the three letter one, for ex. checkbox = chk)... I couldn't find the name for it. Does anyone know the three letter name? Or is it just Tab...?
NikG




PostPosted: Thu Jun 01, 2006 11:28 pm   Post subject: (No subject)

The conventions are not necessarily geared towards specific controls, but rather to the purpose of the control. If you are saying that TabStrip and SSTab serve similar purposes and that TabStrip normally has a tab convention, why not use the same one?
NikG




PostPosted: Thu Jun 01, 2006 11:29 pm   Post subject: (No subject)

On an unrelated note: WOO, that post made me a newbe hacker.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: